store

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2016 License: BSD-3-Clause, AGPL-3.0, Apache-2.0 Imports: 5 Imported by: 0

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

func NewRedisStore(pool *redis.Pool, keyPrefix string, db int) throttled.Store

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.

Jump to

Keyboard shortcuts

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