redis

package
v2.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStore

func NewStore(client Client) (limiter.Store, error)

NewStore returns an instance of redis store with defaults.

func NewStoreWithOptions

func NewStoreWithOptions(client Client, options limiter.StoreOptions) (limiter.Store, error)

NewStoreWithOptions returns an instance of redis store with options.

Types

type Client

type Client interface {
	Ping() *libredis.StatusCmd
	Get(key string) *libredis.StringCmd
	Set(key string, value interface{}, expiration time.Duration) *libredis.StatusCmd
	Watch(handler func(*libredis.Tx) error, keys ...string) error
	Del(keys ...string) *libredis.IntCmd
	SetNX(key string, value interface{}, expiration time.Duration) *libredis.BoolCmd
	Eval(script string, keys []string, args ...interface{}) *libredis.Cmd
}

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.
	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) Peek

func (store *Store) Peek(ctx context.Context, key string, rate limiter.Rate) (limiter.Context, error)

Peek returns the limit for given identifier, without modification on current values.

Jump to

Keyboard shortcuts

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