Documentation ¶
Index ¶
Constants ¶
const NanosecondsPerMillisecond = 1000000
NanosecondsPerMillisecond is used to convert between ns and ms.
const TTLNever time.Duration = -1
TTLNever means do not expire a key
Variables ¶
var ErrNotFound = errors.New("Key not found")
ErrNotFound is returned when an entry is not found in memory database.
Functions ¶
Types ¶
type KeyValueStore ¶
type KeyValueStore interface { Set(key, value string, ttl time.Duration) error Get(key string) (string, error) Del(key string) error FlushDB() error }
KeyValueStore represents simple key value storage.
func NewDefaultMemoryStore ¶
func NewDefaultMemoryStore() KeyValueStore
NewDefaultMemoryStore creates an instance of MemoryKeyValueStore with default settings.
func NewDefaultRedisStore ¶
func NewDefaultRedisStore() (KeyValueStore, error)
NewDefaultRedisStore instantiates Redis.
type MemoryKeyValueStore ¶
MemoryKeyValueStore is an in-memory cache implementation of KeyValueStore.
func NewMemoryKeyValueStore ¶
func NewMemoryKeyValueStore(cleanupInterval time.Duration) *MemoryKeyValueStore
NewMemoryKeyValueStore creates an instance of MemoryKeyValueStore with given backing.
func (*MemoryKeyValueStore) Del ¶
func (store *MemoryKeyValueStore) Del(key string) error
Del deletes value given key.
func (*MemoryKeyValueStore) FlushDB ¶
func (store *MemoryKeyValueStore) FlushDB() error
FlushDB clears all keys
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is a concrete implementation of KeyValueStore for Redis.
func NewRedisStore ¶
func NewRedisStore(ns string, host string, password string) (*RedisStore, error)
NewRedisStore creates a new instance of RedisTokenStore.
func NewRedisStoreFromPool ¶
func NewRedisStoreFromPool(ns string, pool *redis.Pool) *RedisStore
NewRedisStoreFromPool creates a new instance of RedisTokenStore from an existing pool.