Documentation ¶
Overview ¶
Package store offers a memory-based and a Redis-based throttled.Store implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMemStore ¶
func NewMemStore(maxKeys int) throttled.Store
NewMemStore creates a new MemStore. If maxKeys > 0, the number of different keys is restricted to the specified amount. In this case, it uses an LRU algorithm to evict older keys to make room for newer ones. If a request is made for a key that has been evicted, it will be processed as if its count was 0, possibly allowing requests that should be denied.
If maxKeys <= 0, there is no limit on the number of keys, which may use an unbounded amount of memory depending on the server's load.
The MemStore is only for single-process rate-limiting. To share the rate limit state among multiple instances of the web server, use a database- or key-value-based store.
func NewRedisStore ¶
NewRedisStore creates a new Redis-based store, using the provided pool to get its connections. The keys will have the specified keyPrefix, which may be an empty string, and the database index specified by db will be selected to store the keys.
Types ¶
This section is empty.