Documentation
¶
Overview ¶
Package redis contains the Redis store implementation.
Index ¶
- Constants
- Variables
- type Codec
- type Config
- type JSONCodec
- type RawCodec
- type Store
- func (r *Store) AtomicDelete(ctx context.Context, key string, previous *store.KVPair) (bool, error)
- func (r *Store) AtomicPut(ctx context.Context, key string, value []byte, previous *store.KVPair, ...) (bool, *store.KVPair, error)
- func (r *Store) Close() error
- func (r *Store) Delete(ctx context.Context, key string) error
- func (r *Store) DeleteTree(ctx context.Context, directory string) error
- func (r *Store) Exists(ctx context.Context, key string, _ *store.ReadOptions) (bool, error)
- func (r *Store) Get(ctx context.Context, key string, _ *store.ReadOptions) (*store.KVPair, error)
- func (r *Store) List(ctx context.Context, directory string, _ *store.ReadOptions) ([]*store.KVPair, error)
- func (r *Store) NewLock(_ context.Context, key string, opts *store.LockOptions) (store.Locker, error)
- func (r *Store) Put(ctx context.Context, key string, value []byte, opts *store.WriteOptions) error
- func (r *Store) Watch(ctx context.Context, key string, _ *store.ReadOptions) (<-chan *store.KVPair, error)
- func (r *Store) WatchTree(ctx context.Context, directory string, _ *store.ReadOptions) (<-chan []*store.KVPair, error)
Constants ¶
const StoreName = "redis"
StoreName the name of the store.
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 Codec ¶
type Codec interface {
Encode(kv *store.KVPair) (string, error)
Decode(b []byte, kv *store.KVPair) error
}
Codec KVPair persistence interface.
type JSONCodec ¶
type JSONCodec struct{}
JSONCodec is a simple codec to read and write valkeyrie JSON object.
type RawCodec ¶
type RawCodec struct{}
RawCodec is a simple codec to read and write string.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store implements the store.Store interface.
func NewWithCodec ¶
func NewWithCodec(ctx context.Context, endpoints []string, options *Config, codec Codec) (*Store, error)
NewWithCodec creates a new Redis client with codec config.
func (*Store) 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 (*Store) AtomicPut ¶
func (r *Store) AtomicPut(ctx context.Context, key string, value []byte, previous *store.KVPair, opts *store.WriteOptions) (bool, *store.KVPair, 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 (*Store) 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 (*Store) List ¶
func (r *Store) List(ctx context.Context, directory string, _ *store.ReadOptions) ([]*store.KVPair, error)
List the content of a given prefix.
func (*Store) NewLock ¶
func (r *Store) NewLock(_ context.Context, key string, opts *store.LockOptions) (store.Locker, error)
NewLock creates a lock for a given key. The returned Locker is not held and must be acquired with `.Lock`. The Value is optional.
