Documentation ¶
Overview ¶
Package keycounter string型计数器
Index ¶
- Variables
- func WithAutoRefreshInterval(autoRefreshInterval string) optparams.Option[Options]
- func WithKey(key string) optparams.Option[Options]
- func WithMaxTTL(maxTTL time.Duration) optparams.Option[Options]
- func WithNamespace(ns ...string) optparams.Option[Options]
- func WithSpecifiedKey(key string) optparams.Option[Options]
- func WithTaskCron(taskCron *cron.Cron) optparams.Option[Options]
- type Counter
- type Options
Constants ¶
This section is empty.
Variables ¶
View Source
var Defaultopt = Options{ MiddlewareOpts: []optparams.Option[middlewarehelper.Options]{}, }
Defaultopt 默认的可选配置
Functions ¶
func WithAutoRefreshInterval ¶
WithAutoRefreshInterval 设置自动刷新过期时间的设置
func WithMaxTTL ¶
WithMaxTTL 设置token消减间隔时长,单位s
func WithNamespace ¶
WithNamespace 中间件通用设置,指定锁的命名空间
func WithSpecifiedKey ¶
WithSpecifiedKey 中间件通用设置,指定使用的键,注意设置key后namespace将失效
func WithTaskCron ¶
WithTaskCron 设置定时器
Types ¶
type Counter ¶
type Counter struct { *middlewarehelper.MiddleWareAbc // contains filtered or unexported fields }
Counter 分布式计数器
func New ¶
New 创建一个新的位图对象 @params cli redis.UniversalClient redis客户端对象 @params opts ...optparams.Option[Options] 配置项
func (*Counter) Next ¶
Next 加1后的当前计数值 如果设置了MaxTTL则会在执行好后刷新TTL @params ctx context.Context 上下文信息,用于控制请求的结束
Click to show internal directories.
Click to hide internal directories.