Documentation
¶
Index ¶
- type DummyStore
- func (s DummyStore) AppendSlice(key string, values ...interface{}) error
- func (s DummyStore) Close() error
- func (s DummyStore) Delete(key string) error
- func (s DummyStore) Exists(key string) (bool, error)
- func (s DummyStore) Flush() error
- func (s DummyStore) Get(key string) (interface{}, error)
- func (s DummyStore) GetMap(key string) (map[string]interface{}, error)
- func (s DummyStore) GetSlice(key string) ([]interface{}, error)
- func (s DummyStore) Set(key string, value interface{}) error
- func (s DummyStore) SetMap(key string, value map[string]interface{}) error
- func (s DummyStore) SetSlice(key string, value []interface{}) 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) 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) GetSlice(key 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) SetSlice(key string, value []interface{}) error
- type RedisClient
- type RedisClientOptions
- type RedisClusterOptions
- 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) 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) GetSlice(key string) ([]interface{}, error)
- func (r *RedisStore) Set(key string, value interface{}) error
- func (r *RedisStore) SetMap(key string, values map[string]interface{}) error
- func (r *RedisStore) SetSlice(key string, values []interface{}) 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 (s DummyStore) AppendSlice(key string, values ...interface{}) error
AppendSlice appends values to an existing slice. If key does not exist, creates slice.
func (DummyStore) Close ¶
func (s DummyStore) Close() error
Close closes the connection to the store.
func (DummyStore) Delete ¶
func (s DummyStore) Delete(key string) error
Delete deletes the given key.
func (DummyStore) Exists ¶
func (s DummyStore) Exists(key string) (bool, error)
Exists checks if the given key exists.
func (DummyStore) Get ¶
func (s DummyStore) Get(key string) (interface{}, error)
Get returns value for the given key.
func (DummyStore) GetMap ¶
func (s DummyStore) GetMap(key string) (map[string]interface{}, error)
GetMap returns map for the given key.
func (DummyStore) GetSlice ¶
func (s DummyStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
func (DummyStore) Set ¶
func (s DummyStore) Set(key string, value interface{}) error
Set sets value for the given key.
func (DummyStore) SetMap ¶
func (s DummyStore) SetMap(key string, value map[string]interface{}) error
SetMap sets map for the given key.
func (DummyStore) SetSlice ¶
func (s DummyStore) SetSlice(key string, value []interface{}) error
SetSlice sets slice for the given key.
type KVStore ¶
type KVStore interface {
// Get returns value for the given key.
Get(key string) (interface{}, error)
// Set sets value for the given key.
Set(key string, value interface{}) error
// GetMap returns map for the given key.
GetMap(key string) (map[string]interface{}, error)
// SetMap sets map for the given key.
SetMap(key string, value map[string]interface{}) 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
// 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) 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) GetSlice ¶
func (c *MemoryStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
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) SetSlice ¶
func (c *MemoryStore) SetSlice(key string, value []interface{}) error
SetSlice sets slice for the given key.
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
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
}
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 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) 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) GetSlice ¶
func (r *RedisStore) GetSlice(key string) ([]interface{}, error)
GetSlice returns slice for the given key.
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) SetSlice ¶
func (r *RedisStore) SetSlice(key string, values []interface{}) error
SetSlice sets map for the given key.