bitmapset

package
v2.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package bitmap bitmap操作支持 bitmap可以用于分布式去重 bitmap实现了一般set的常用接口(Add,Remove,Contained,Len,ToArray)

Index

Constants

This section is empty.

Variables

View Source
var Defaultopt = Options{
	MiddlewareOpts: []optparams.Option[middlewarehelper.Options]{},
}

Defaultopt 默认的可选配置

Functions

func ScopIndex

func ScopIndex(index int64) optparams.Option[redis.BitCount]

ScopTo 排序的上限

func ScopRange

func ScopRange(from, to int64) optparams.Option[redis.BitCount]

ScopFrom 排序的下限

func WithAutoRefreshInterval

func WithAutoRefreshInterval(autoRefreshInterval string) optparams.Option[Options]

WithAutoRefreshInterval 设置自动刷新过期时间的设置

func WithKey

func WithKey(key string) optparams.Option[Options]

WithKey 中间件通用设置,指定使用的键,注意设置后namespace依然有效

func WithMaxTTL

func WithMaxTTL(maxTTL time.Duration) optparams.Option[Options]

WithMaxTTL 设置token消减间隔时长,单位s

func WithNamespace

func WithNamespace(ns ...string) optparams.Option[Options]

WithNamespace 中间件通用设置,指定锁的命名空间

func WithSpecifiedKey

func WithSpecifiedKey(key string) optparams.Option[Options]

WithSpecifiedKey 中间件通用设置,指定使用的键,注意设置key后namespace将失效

func WithTaskCron

func WithTaskCron(taskCron *cron.Cron) optparams.Option[Options]

WithTaskCron 设置定时器

Types

type Bitmap

type Bitmap struct {
	*middlewarehelper.MiddleWareAbc
	// contains filtered or unexported fields
}

Bitmap 位图对象

func New

func New(cli redis.UniversalClient, opts ...optparams.Option[Options]) (*Bitmap, error)

New 创建一个新的位图对象 @params k *key.Key redis客户端的键对象

func (*Bitmap) Add

func (bm *Bitmap) Add(ctx context.Context, offset int64) error

Add 为bitmap中固定偏移量位置置1 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params offset int64 要置1的偏移量

func (*Bitmap) AddM

func (bm *Bitmap) AddM(ctx context.Context, offsets ...int64) error

AddM 为bitmap中多个偏移量位置置1 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params offsets ...int64 要置1的偏移量

func (*Bitmap) Contained

func (bm *Bitmap) Contained(ctx context.Context, offset int64) (bool, error)

Contained 检查bitmap某偏移量是否已经被置1 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params offset int64 查看的偏移量

func (*Bitmap) Except

func (bm *Bitmap) Except(ctx context.Context, otherbm *Bitmap, newopts ...optparams.Option[Options]) (*Bitmap, error)

Except 对应set的求差集操作 @params ctx context.Context 上下文信息,用于控制请求的结束 @params targetbmkey *clientkey.ClientKey 目标key对象 @params otherbm *Bitmap 与之做xor操作的其他bitmap对象

func (*Bitmap) Intersection

func (bm *Bitmap) Intersection(ctx context.Context, otherbms []*Bitmap, newopts ...optparams.Option[Options]) (*Bitmap, error)

Intersection 对应set的求交集操作 @params ctx context.Context 上下文信息,用于控制请求的结束 @params targetbmkey *clientkey.ClientKey 目标key对象 @params otherbms ...*Bitmap 与之做交操作的其他bitmap对象

func (*Bitmap) Len

func (bm *Bitmap) Len(ctx context.Context) (int64, error)

Len 检查bitmap中被置1的有多少位 规定报错时返回的第一位是-1 如果key设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束

func (*Bitmap) Remove

func (bm *Bitmap) Remove(ctx context.Context, offset int64) error

Remove 为bitmap中固定偏移量位置置0 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params offset int64 要置0的偏移量

func (*Bitmap) RemoveM

func (bm *Bitmap) RemoveM(ctx context.Context, offsets ...int64) error

RemoveM 为bitmap中多个偏移量位置置0 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params offsets ...int64 要置0的偏移量

func (*Bitmap) Reset

func (bm *Bitmap) Reset(ctx context.Context) error

Reset 重置当前bitmap @params ctx context.Context 上下文信息,用于控制请求的结束

func (*Bitmap) ScopCount

func (bm *Bitmap) ScopCount(ctx context.Context, opts ...optparams.Option[redis.BitCount]) (int64, error)

ScopCount 检查bitmap中特定范围内被置1的有多少位 规定报错时返回的第一位是-1 如果key设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束 @params scop ...int64 最多2位,第一位表示开始位置,第二位表示结束位置,注意参数scop只能精确到bit, 也就是说,0到7都表示实际填入的0;8,15都表示实际填入的1...,如果只有一位scop则表示查看某一位内的个数

func (*Bitmap) ToArray

func (bm *Bitmap) ToArray(ctx context.Context) ([]int64, error)

ToArray 检查哪些偏移量是已经被置1的 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束

func (*Bitmap) Union

func (bm *Bitmap) Union(ctx context.Context, otherbms []*Bitmap, newopts ...optparams.Option[Options]) (*Bitmap, error)

Union 对应set的求并集操作 @params ctx context.Context 上下文信息,用于控制请求的结束 @params targetbmkey *clientkey.ClientKey 目标key对象 @params otherbms ...*Bitmap 与之做并操作的其他bitmap对象

func (*Bitmap) Xor

func (bm *Bitmap) Xor(ctx context.Context, otherbm *Bitmap, newopts ...optparams.Option[Options]) (*Bitmap, error)

Xor 对应set的求对称差集操作 @params ctx context.Context 上下文信息,用于控制请求的结束 @params targetbmkey *clientkey.ClientKey 目标key对象 @params otherbm *Bitmap 与之做xor操作的其他bitmap对象

type Options

type Options struct {
	MiddlewareOpts []optparams.Option[middlewarehelper.Options] //初始化Middleware的配置
}

Options broker的配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL