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(ctx context.Context, keys ...string) *redis.IntCmd
- func (r RedisPipeline) Exists(ctx context.Context, key ...string) *redis.IntCmd
- func (r RedisPipeline) FlushDB(ctx context.Context) *redis.StatusCmd
- func (r RedisPipeline) Get(ctx context.Context, key string) *redis.StringCmd
- func (r RedisPipeline) HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd
- func (r RedisPipeline) HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd
- func (r RedisPipeline) HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd
- func (r RedisPipeline) Keys(ctx context.Context, pattern string) *redis.StringSliceCmd
- func (r RedisPipeline) MGet(ctx context.Context, keys ...string) *redis.SliceCmd
- func (r RedisPipeline) Ping(ctx context.Context) *redis.StatusCmd
- func (r RedisPipeline) Pipeline() redis.Pipeliner
- func (r RedisPipeline) Process(ctx context.Context, cmd redis.Cmder) error
- func (r RedisPipeline) SAdd(ctx context.Context, key string, members ...interface{}) *redis.IntCmd
- func (r RedisPipeline) SMembers(ctx context.Context, key string) *redis.StringSliceCmd
- func (r RedisPipeline) Set(ctx context.Context, 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(ctx context.Context) *redis.StatusCmd Exists(ctx context.Context, key ...string) *redis.IntCmd Del(ctx context.Context, keys ...string) *redis.IntCmd FlushDB(ctx context.Context) *redis.StatusCmd Close() error Process(ctx context.Context, cmd redis.Cmder) error Get(ctx context.Context, key string) *redis.StringCmd Set(ctx context.Context, key string, value interface{}, expiration time.Duration) *redis.StatusCmd MGet(ctx context.Context, keys ...string) *redis.SliceCmd HDel(ctx context.Context, key string, fields ...string) *redis.IntCmd HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd HMSet(ctx context.Context, key string, values ...interface{}) *redis.BoolCmd SMembers(ctx context.Context, key string) *redis.StringSliceCmd SAdd(ctx context.Context, key string, members ...interface{}) *redis.IntCmd Keys(ctx context.Context, pattern string) *redis.StringSliceCmd Pipeline() redis.Pipeliner }
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(ctx context.Context, network, addr string) (net.Conn, error) Username string 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 UseTLS bool }
RedisClientOptions are Redis client options.
type RedisClusterOptions ¶
type RedisClusterOptions struct { Addrs []string MaxRedirects int ReadOnly bool RouteByLatency bool Username string Password string DialTimeout time.Duration ReadTimeout time.Duration WriteTimeout time.Duration PoolSize int PoolTimeout time.Duration IdleTimeout time.Duration IdleCheckFrequency time.Duration UseTLS bool }
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) FlushDB ¶
func (r RedisPipeline) FlushDB(ctx context.Context) *redis.StatusCmd
FlushDb implements RedisClient FlushDb for pipeline
func (RedisPipeline) HGetAll ¶
func (r RedisPipeline) HGetAll(ctx context.Context, key string) *redis.StringStringMapCmd
HGetAll implements RedisClient HGetAll for pipeline
func (RedisPipeline) Keys ¶
func (r RedisPipeline) Keys(ctx context.Context, pattern string) *redis.StringSliceCmd
Keys implements RedisClient Keys for pipeline
func (RedisPipeline) Ping ¶
func (r RedisPipeline) Ping(ctx context.Context) *redis.StatusCmd
Ping implements RedisClient Ping for pipeline
func (RedisPipeline) Pipeline ¶
func (r RedisPipeline) Pipeline() redis.Pipeliner
Pipeline returns Redis pipeline
func (RedisPipeline) SMembers ¶
func (r RedisPipeline) SMembers(ctx context.Context, 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.