Documentation ¶
Index ¶
- type DummyStore
- func (DummyStore) AppendSlice(key string, values ...interface{}) error
- func (DummyStore) Close() error
- func (DummyStore) Delete(key string) error
- func (DummyStore) DeleteMap(key string, fields ...string) error
- func (DummyStore) Exists(key string) (bool, error)
- func (DummyStore) Flush() error
- func (DummyStore) Get(key string) (interface{}, error)
- func (DummyStore) GetMap(key string) (map[string]interface{}, error)
- func (DummyStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
- func (DummyStore) GetSlice(key string) ([]interface{}, error)
- func (DummyStore) Keys(pattern string) ([]interface{}, error)
- func (DummyStore) MGet(keys []string) (map[string]interface{}, error)
- func (DummyStore) Set(key string, value interface{}) error
- func (DummyStore) SetMap(key string, value map[string]interface{}) error
- func (DummyStore) SetMaps(maps map[string]map[string]interface{}) error
- func (DummyStore) SetSlice(key string, value []interface{}) error
- func (DummyStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
- type KVStore
- type MemoryStore
- func (c *MemoryStore) AppendSlice(key string, values ...interface{}) error
- func (c *MemoryStore) Close() error
- func (c *MemoryStore) Delete(key string) error
- func (c *MemoryStore) DeleteMap(key string, fields ...string) error
- func (c *MemoryStore) Exists(key string) (bool, error)
- func (c *MemoryStore) Flush() error
- func (c *MemoryStore) Get(key string) (interface{}, error)
- func (c *MemoryStore) GetMap(key string) (map[string]interface{}, error)
- func (c *MemoryStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
- func (c *MemoryStore) GetSlice(key string) ([]interface{}, error)
- func (c *MemoryStore) Keys(pattern string) ([]interface{}, error)
- func (c *MemoryStore) MGet(keys []string) (map[string]interface{}, error)
- func (c *MemoryStore) Set(key string, value interface{}) error
- func (c *MemoryStore) SetMap(key string, value map[string]interface{}) error
- func (c *MemoryStore) SetMaps(maps map[string]map[string]interface{}) error
- func (c *MemoryStore) SetSlice(key string, value []interface{}) error
- func (c *MemoryStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
- type RedisClient
- type RedisClientOptions
- type RedisClusterOptions
- type RedisPipeline
- func (r RedisPipeline) Close() error
- func (r RedisPipeline) Del(keys ...string) *redis.IntCmd
- func (r RedisPipeline) Exists(key string) *redis.BoolCmd
- func (r RedisPipeline) FlushDb() *redis.StatusCmd
- func (r RedisPipeline) Get(key string) *redis.StringCmd
- func (r RedisPipeline) HDel(key string, fields ...string) *redis.IntCmd
- func (r RedisPipeline) HGetAll(key string) *redis.StringStringMapCmd
- func (r RedisPipeline) HMSet(key string, fields map[string]string) *redis.StatusCmd
- func (r RedisPipeline) Keys(pattern string) *redis.StringSliceCmd
- func (r RedisPipeline) MGet(keys ...string) *redis.SliceCmd
- func (r RedisPipeline) Ping() *redis.StatusCmd
- func (r RedisPipeline) Pipeline() *redis.Pipeline
- func (r RedisPipeline) Process(cmd redis.Cmder) error
- func (r RedisPipeline) SAdd(key string, members ...interface{}) *redis.IntCmd
- func (r RedisPipeline) SMembers(key string) *redis.StringSliceCmd
- func (r RedisPipeline) Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd
- type RedisStore
- func (r *RedisStore) AppendSlice(key string, values ...interface{}) error
- func (r *RedisStore) Close() error
- func (r *RedisStore) Delete(key string) error
- func (r *RedisStore) DeleteMap(key string, fields ...string) error
- func (r *RedisStore) Exists(key string) (bool, error)
- func (r *RedisStore) Flush() error
- func (r *RedisStore) Get(key string) (interface{}, error)
- func (r *RedisStore) GetMap(key string) (map[string]interface{}, error)
- func (r *RedisStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
- func (r *RedisStore) GetSlice(key string) ([]interface{}, error)
- func (r *RedisStore) Keys(pattern string) ([]interface{}, error)
- func (r *RedisStore) MGet(keys []string) (map[string]interface{}, error)
- func (r *RedisStore) Pipeline(f func(r *RedisStore) error) ([]redis.Cmder, error)
- func (r *RedisStore) Set(key string, value interface{}) error
- func (r *RedisStore) SetMap(key string, values map[string]interface{}) error
- func (r *RedisStore) SetMaps(maps map[string]map[string]interface{}) error
- func (r *RedisStore) SetSlice(key string, values []interface{}) error
- func (r *RedisStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyStore ¶
type DummyStore struct{}
DummyStore is a noop store (caching disabled).
func (DummyStore) AppendSlice ¶
func (DummyStore) AppendSlice(key string, values ...interface{}) error
AppendSlice appends values to an existing slice. If key does not exist, creates slice.
func (DummyStore) DeleteMap ¶
func (DummyStore) DeleteMap(key string, fields ...string) error
DeleteMap removes the specified fields from the map stored at key.
func (DummyStore) Exists ¶
func (DummyStore) Exists(key string) (bool, error)
Exists checks if the given key exists.
func (DummyStore) Get ¶
func (DummyStore) Get(key string) (interface{}, error)
Get returns value for the given key.
func (DummyStore) GetMap ¶
func (DummyStore) GetMap(key string) (map[string]interface{}, error)
GetMap returns map for the given key.
func (DummyStore) GetMaps ¶
func (DummyStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
GetMaps returns maps for the given keys.
func (DummyStore) GetSlice ¶
func (DummyStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
func (DummyStore) Keys ¶
func (DummyStore) Keys(pattern string) ([]interface{}, error)
Keys returns all keys matching pattern
func (DummyStore) MGet ¶
func (DummyStore) MGet(keys []string) (map[string]interface{}, error)
MGet returns map of key, value for a list of keys.
func (DummyStore) Set ¶
func (DummyStore) Set(key string, value interface{}) error
Set sets value for the given key.
func (DummyStore) SetMap ¶
func (DummyStore) SetMap(key string, value map[string]interface{}) error
SetMap sets map for the given key.
func (DummyStore) SetMaps ¶
func (DummyStore) SetMaps(maps map[string]map[string]interface{}) error
SetMaps sets the given maps.
func (DummyStore) SetSlice ¶
func (DummyStore) SetSlice(key string, value []interface{}) error
SetSlice sets slice for the given key.
func (DummyStore) SetWithExpiration ¶
func (DummyStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
SetWithExpiration sets the value for the given key for a specified duration.
type KVStore ¶
type KVStore interface { // Get returns value for the given key. Get(key string) (interface{}, error) // MGet returns map of key, value for a list of keys. MGet(keys []string) (map[string]interface{}, error) // Set sets value for the given key. Set(key string, value interface{}) error // SetWithExpiration sets the value for the given key for a specified duration. SetWithExpiration(key string, value interface{}, expiration time.Duration) error // GetMap returns map for the given key. GetMap(key string) (map[string]interface{}, error) // GetMaps returns maps for the given keys. GetMaps(keys []string) (map[string]map[string]interface{}, error) // SetMap sets map for the given key. SetMap(key string, value map[string]interface{}) error // SetMaps sets the given maps. SetMaps(maps map[string]map[string]interface{}) error // DeleteMap removes the specified fields from the map stored at key. DeleteMap(key string, fields ...string) error // GetSlice returns slice for the given key. GetSlice(key string) ([]interface{}, error) // SetSlice sets slice for the given key. SetSlice(key string, value []interface{}) error // AppendSlice appends values to an existing slice. // If key does not exist, creates slice. AppendSlice(key string, values ...interface{}) error // Exists checks if the given key exists. Exists(key string) (bool, error) // Delete deletes the given key. Delete(key string) error // Flush flushes the store. Flush() error // Return all keys matching pattern Keys(pattern string) ([]interface{}, error) // Close closes the connection to the store. Close() error }
KVStore is the KV store interface.
func NewMemoryStore ¶
NewMemoryStore returns in-memory KVStore.
func NewRedisClientStore ¶
func NewRedisClientStore(options *RedisClientOptions, expiration time.Duration) (KVStore, error)
NewRedisClientStore returns Redis client instance of KVStore.
func NewRedisClusterStore ¶
func NewRedisClusterStore(options *RedisClusterOptions, expiration time.Duration) (KVStore, error)
NewRedisClusterStore returns Redis cluster client instance of KVStore.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is the in-memory implementation of KVStore.
func (*MemoryStore) AppendSlice ¶
func (c *MemoryStore) AppendSlice(key string, values ...interface{}) error
AppendSlice appends values to the given slice.
func (*MemoryStore) Close ¶
func (c *MemoryStore) Close() error
Close does nothing for this backend.
func (*MemoryStore) Delete ¶
func (c *MemoryStore) Delete(key string) error
Delete deletes the given key.
func (*MemoryStore) DeleteMap ¶
func (c *MemoryStore) DeleteMap(key string, fields ...string) error
DeleteMap removes the specified fields from the map stored at key.
func (*MemoryStore) Exists ¶
func (c *MemoryStore) Exists(key string) (bool, error)
Exists checks if the given key exists.
func (*MemoryStore) Flush ¶
func (c *MemoryStore) Flush() error
Flush removes all items from the cache.
func (*MemoryStore) Get ¶
func (c *MemoryStore) Get(key string) (interface{}, error)
Get returns item from the cache.
func (*MemoryStore) GetMap ¶
func (c *MemoryStore) GetMap(key string) (map[string]interface{}, error)
GetMap returns map for the given key.
func (*MemoryStore) GetMaps ¶
func (c *MemoryStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
GetMaps returns maps for the given keys.
func (*MemoryStore) GetSlice ¶
func (c *MemoryStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
func (*MemoryStore) Keys ¶
func (c *MemoryStore) Keys(pattern string) ([]interface{}, error)
Keys returns all keys matching pattern
func (*MemoryStore) MGet ¶
func (c *MemoryStore) MGet(keys []string) (map[string]interface{}, error)
MGet returns map of key, value for a list of keys.
func (*MemoryStore) Set ¶
func (c *MemoryStore) Set(key string, value interface{}) error
Set sets value in the cache.
func (*MemoryStore) SetMap ¶
func (c *MemoryStore) SetMap(key string, value map[string]interface{}) error
SetMap sets a map for the given key.
func (*MemoryStore) SetMaps ¶
func (c *MemoryStore) SetMaps(maps map[string]map[string]interface{}) error
SetMaps sets the given maps.
func (*MemoryStore) SetSlice ¶
func (c *MemoryStore) SetSlice(key string, value []interface{}) error
SetSlice sets slice for the given key.
func (*MemoryStore) SetWithExpiration ¶
func (c *MemoryStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
SetWithExpiration sets the value for the given key for a specified duration.
type RedisClient ¶
type RedisClient interface { Ping() *redis.StatusCmd Exists(key string) *redis.BoolCmd Del(keys ...string) *redis.IntCmd FlushDb() *redis.StatusCmd Close() error Process(cmd redis.Cmder) error Get(key string) *redis.StringCmd Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd MGet(keys ...string) *redis.SliceCmd HDel(key string, fields ...string) *redis.IntCmd HGetAll(key string) *redis.StringStringMapCmd HMSet(key string, fields map[string]string) *redis.StatusCmd SMembers(key string) *redis.StringSliceCmd SAdd(key string, members ...interface{}) *redis.IntCmd Keys(pattern string) *redis.StringSliceCmd Pipeline() *redis.Pipeline }
RedisClient is an interface thats allows to use Redis cluster or a redis single client seamlessly.
type RedisClientOptions ¶
type RedisClientOptions struct { Network string Addr string Dialer func() (net.Conn, error) Password string DB int MaxRetries int DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration PoolSize int PoolTimeout time.Duration IdleTimeout time.Duration IdleCheckFrequency time.Duration ReadOnly bool }
RedisClientOptions are Redis client options.
type RedisClusterOptions ¶
type RedisClusterOptions struct { Addrs []string MaxRedirects int ReadOnly bool RouteByLatency bool Password string DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration PoolSize int PoolTimeout time.Duration IdleTimeout time.Duration IdleCheckFrequency time.Duration }
RedisClusterOptions are Redis cluster options.
type RedisPipeline ¶
type RedisPipeline struct {
// contains filtered or unexported fields
}
RedisPipeline is a struct which contains an opend redis pipeline transaction
func (RedisPipeline) Close ¶
func (r RedisPipeline) Close() error
Close implements RedisClient Close for pipeline
func (RedisPipeline) Del ¶
func (r RedisPipeline) Del(keys ...string) *redis.IntCmd
Del implements RedisClient Del for pipeline
func (RedisPipeline) Exists ¶
func (r RedisPipeline) Exists(key string) *redis.BoolCmd
Exists implements RedisClient Exists for pipeline
func (RedisPipeline) FlushDb ¶
func (r RedisPipeline) FlushDb() *redis.StatusCmd
FlushDb implements RedisClient FlushDb for pipeline
func (RedisPipeline) Get ¶
func (r RedisPipeline) Get(key string) *redis.StringCmd
Get implements RedisClient Get for pipeline
func (RedisPipeline) HDel ¶
func (r RedisPipeline) HDel(key string, fields ...string) *redis.IntCmd
HDel implements RedisClient HDel for pipeline
func (RedisPipeline) HGetAll ¶
func (r RedisPipeline) HGetAll(key string) *redis.StringStringMapCmd
HGetAll implements RedisClient HGetAll for pipeline
func (RedisPipeline) Keys ¶
func (r RedisPipeline) Keys(pattern string) *redis.StringSliceCmd
Keys implements RedisClient Keys for pipeline
func (RedisPipeline) MGet ¶
func (r RedisPipeline) MGet(keys ...string) *redis.SliceCmd
MGet implements RedisClient MGet for pipeline
func (RedisPipeline) Ping ¶
func (r RedisPipeline) Ping() *redis.StatusCmd
Ping implements RedisClient Ping for pipeline
func (RedisPipeline) Pipeline ¶
func (r RedisPipeline) Pipeline() *redis.Pipeline
Pipeline returns Redis pipeline
func (RedisPipeline) Process ¶
func (r RedisPipeline) Process(cmd redis.Cmder) error
Process implements RedisClient Process for pipeline
func (RedisPipeline) SAdd ¶
func (r RedisPipeline) SAdd(key string, members ...interface{}) *redis.IntCmd
SAdd implements RedisClient SAdd for pipeline
func (RedisPipeline) SMembers ¶
func (r RedisPipeline) SMembers(key string) *redis.StringSliceCmd
SMembers implements RedisClient SMembers for pipeline
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore is the Redis implementation of KVStore.
func (*RedisStore) AppendSlice ¶
func (r *RedisStore) AppendSlice(key string, values ...interface{}) error
AppendSlice appends values to the given slice.
func (*RedisStore) DeleteMap ¶
func (r *RedisStore) DeleteMap(key string, fields ...string) error
DeleteMap removes the specified fields from the map stored at key.
func (*RedisStore) Exists ¶
func (r *RedisStore) Exists(key string) (bool, error)
Exists checks key existence.
func (*RedisStore) Get ¶
func (r *RedisStore) Get(key string) (interface{}, error)
Get returns value for the given key.
func (*RedisStore) GetMap ¶
func (r *RedisStore) GetMap(key string) (map[string]interface{}, error)
GetMap returns map for the given key.
func (*RedisStore) GetMaps ¶
func (r *RedisStore) GetMaps(keys []string) (map[string]map[string]interface{}, error)
GetMaps returns maps for the given keys.
func (*RedisStore) GetSlice ¶
func (r *RedisStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
func (*RedisStore) Keys ¶
func (r *RedisStore) Keys(pattern string) ([]interface{}, error)
Keys returns all keys matching pattern.
func (*RedisStore) MGet ¶
func (r *RedisStore) MGet(keys []string) (map[string]interface{}, error)
MGet returns map of key, value for a list of keys.
func (*RedisStore) Pipeline ¶
func (r *RedisStore) Pipeline(f func(r *RedisStore) error) ([]redis.Cmder, error)
Pipeline uses pipeline as a Redis client to execute multiple calls at once
func (*RedisStore) Set ¶
func (r *RedisStore) Set(key string, value interface{}) error
Set sets the value for the given key.
func (*RedisStore) SetMap ¶
func (r *RedisStore) SetMap(key string, values map[string]interface{}) error
SetMap sets map for the given key.
func (*RedisStore) SetMaps ¶
func (r *RedisStore) SetMaps(maps map[string]map[string]interface{}) error
SetMaps sets the given maps.
func (*RedisStore) SetSlice ¶
func (r *RedisStore) SetSlice(key string, values []interface{}) error
SetSlice sets map for the given key.
func (*RedisStore) SetWithExpiration ¶
func (r *RedisStore) SetWithExpiration(key string, value interface{}, expiration time.Duration) error
SetWithExpiration sets the value for the given key.