Documentation ¶
Index ¶
- func NewStore(client Client) (limiter.Store, error)
- func NewStoreWithOptions(client Client, options limiter.StoreOptions) (limiter.Store, error)
- type Client
- type Store
- func (store *Store) Get(ctx context.Context, key string, rate limiter.Rate) (limiter.Context, error)
- func (store *Store) Increment(ctx context.Context, key string, count int64, rate limiter.Rate) (limiter.Context, error)
- func (store *Store) Peek(ctx context.Context, key string, rate limiter.Rate) (limiter.Context, error)
- func (store *Store) Reset(ctx context.Context, key string, rate limiter.Rate) (limiter.Context, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStoreWithOptions ¶
NewStoreWithOptions returns an instance of redis store with options.
Types ¶
type Client ¶
type Client interface { Get(ctx context.Context, key string) *libredis.StringCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *libredis.StatusCmd Watch(ctx context.Context, handler func(*libredis.Tx) error, keys ...string) error Del(ctx context.Context, keys ...string) *libredis.IntCmd SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) *libredis.BoolCmd EvalSha(ctx context.Context, sha string, keys []string, args ...interface{}) *libredis.Cmd ScriptLoad(ctx context.Context, script string) *libredis.StringCmd }
Client is an interface thats allows to use a redis cluster or a redis single client seamlessly.
type Store ¶
type Store struct { // Prefix used for the key. Prefix string // MaxRetry is the maximum number of retry under race conditions. // Deprecated: this option is no longer required since all operations are atomic now. MaxRetry int // contains filtered or unexported fields }
Store is the redis store.
func (*Store) Get ¶
func (store *Store) Get(ctx context.Context, key string, rate limiter.Rate) (limiter.Context, error)
Get returns the limit for given identifier.
func (*Store) Increment ¶ added in v3.9.0
func (store *Store) Increment(ctx context.Context, key string, count int64, rate limiter.Rate) (limiter.Context, error)
Increment increments the limit by given count & gives back the new limit for given identifier
Click to show internal directories.
Click to hide internal directories.