Documentation ¶
Index ¶
- Variables
- type Redis
- func (r *Redis) AtomicDelete(key string, previous *store.KeyValue) (bool, error)
- func (r *Redis) AtomicPut(key string, value []byte, previous *store.KeyValue, options ...store.PutOption) (*store.KeyValue, error)
- func (r *Redis) Close()
- func (r *Redis) Delete(key string) error
- func (r *Redis) DeleteTree(directory string) error
- func (r *Redis) Exists(key string) (bool, error)
- func (r *Redis) Get(key string) (*store.KeyValue, error)
- func (r *Redis) List(directory string) ([]*store.KeyValue, error)
- func (r *Redis) Lock(key string, options ...store.LockOption) (store.Locker, error)
- func (r *Redis) Ping() error
- func (r *Redis) Put(key string, value []byte, options ...store.PutOption) error
- func (r *Redis) Watch(key string, stopCh <-chan struct{}) (<-chan *store.KeyValue, error)
- func (r *Redis) WatchTree(directory string, stopCh <-chan struct{}) (<-chan []*store.KeyValue, error)
- type RedisOption
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMultipleEndpointsUnsupported is thrown when there are // multiple endpoints specified for Redis ErrMultipleEndpointsUnsupported = errors.New("redis does not support multiple endpoints") // ErrAbortTryLock is thrown when a user stops trying to seek the lock // by sending a signal to the stop chan, this is used to verify if the // operation succeeded ErrAbortTryLock = errors.New("redis: lock operation aborted") )
Functions ¶
This section is empty.
Types ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis implements libkv.Store interface with redis backend
func New ¶
func New(endpoints []string, notification bool, options ...RedisOption) (*Redis, error)
New creates a new Redis client given a list of endpoints and optional config
func (*Redis) AtomicDelete ¶
AtomicDelete is an atomic delete operation on a single value the value will be deleted if previous matched the one stored in db
func (*Redis) AtomicPut ¶
func (r *Redis) AtomicPut(key string, value []byte, previous *store.KeyValue, options ...store.PutOption) (*store.KeyValue, error)
AtomicPut is an atomic CAS operation on a single value. Pass previous = nil to create a new key. we introduced script on this page, so atomicity is guaranteed
func (*Redis) DeleteTree ¶
DeleteTree deletes a range of keys under a given directory glitch: we list all available keys first and then delete them all it costs two operations on redis, so is not atomicity.
func (*Redis) Lock ¶
NewLock creates a lock for a given key. The returned Locker is not held and must be acquired with `.Lock`. The Value is optional.
type RedisOption ¶
type RedisOption func(*redis.Options)
func DialTimeout ¶
func DialTimeout(t time.Duration) RedisOption
func Password ¶
func Password(pwd string) RedisOption
func PoolSize ¶
func PoolSize(size int) RedisOption
func PoolTimeout ¶
func PoolTimeout(t time.Duration) RedisOption
func ReadTimeout ¶
func ReadTimeout(t time.Duration) RedisOption
func WriteTimeout ¶
func WriteTimeout(t time.Duration) RedisOption