redis

package
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Name of the Key/Value Store within the registry
	Name = "redis"
)

Variables

This section is empty.

Functions

func New

func New(mo store.MergeOperator, config map[string]interface{}) (store.KVStore, error)

New creates a new KVStore which persists its data on Redis. It requires at least a config value for "url". Further config values are:

  • db(optional) The database number. Must be parseable to an int
  • connection_timeout (optional) The timeout after which a connection attempt to Redis is abandoned. Must be parseable to time.Duration
  • read_timeout (optional) The timeout after which a single read operation is abandoned. Must be parseable to time.Duration
  • write_timeout (optional) The timeout after which a single write operation is abandoned. Must be parseable to time.Duration
  • use_tls (optional) Wether to use TLS to connect to Redis or not. Must be parseable to a boolean.
  • tls_skip_verify (optional) Wether to validate the server's certificate or not. Only evaluated when use_tls is true. Must be parseable to a boolean.
  • password (optional) String containing the password for Redis.

Types

type Iterator

type Iterator struct {
	// contains filtered or unexported fields
}

Iterator statisfies both the PrefixIterator and the RangeIterator interface. As PrefixIterator, it will visit all K/V pairs with the provided prefix. As RangeIterator, it will visit all K/V pairs between start and end.

func (Iterator) Close

func (i Iterator) Close() error

Close closes the iterator

func (Iterator) Current

func (i Iterator) Current() ([]byte, []byte, bool)

Current returns Key(),Value(),Valid() in a single operation

func (Iterator) Key

func (i Iterator) Key() []byte

Key returns the key pointed to by the iterator The bytes returned are **ONLY** valid until the next call to Seek/Next/Close Continued use after that requires that they be copied.

func (Iterator) Next

func (i Iterator) Next()

Next will advance the iterator to the next key

func (Iterator) Seek

func (i Iterator) Seek(key []byte)

Seek will advance the iterator to the specified key

func (Iterator) Valid

func (i Iterator) Valid() bool

Valid returns whether or not the iterator is in a valid state

func (Iterator) Value

func (i Iterator) Value() []byte

Value returns the value pointed to by the iterator The bytes returned are **ONLY** valid until the next call to Seek/Next/Close Continued use after that requires that they be copied.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements the KVReader interface for a Redis backend.

func (Reader) Close

func (r Reader) Close() error

Close closes the Reader.

func (Reader) Get

func (r Reader) Get(key []byte) ([]byte, error)

Get returns the value associated with the key If the key does not exist, nil is returned. The caller owns the bytes returned.

func (Reader) MultiGet

func (r Reader) MultiGet(keys [][]byte) ([][]byte, error)

MultiGet retrieves multiple values in one call.

func (Reader) PrefixIterator

func (r Reader) PrefixIterator(prefix []byte) store.KVIterator

PrefixIterator returns a KVIterator that will visit all K/V pairs with the provided prefix

func (Reader) RangeIterator

func (r Reader) RangeIterator(start, end []byte) store.KVIterator

RangeIterator returns a KVIterator that will visit all K/V pairs >= start AND < end

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements the KVStore interface for a Redis.

func (Store) Close

func (s Store) Close() (err error)

Close flushes the connection to Redis and closes it.

func (Store) Reader

func (s Store) Reader() (store.KVReader, error)

func (Store) Writer

func (s Store) Writer() (store.KVWriter, error)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer is used to write values to Redis.

func (Writer) Close

func (w Writer) Close() error

Close closes the writer

func (Writer) ExecuteBatch

func (w Writer) ExecuteBatch(batch store.KVBatch) error

ExecuteBatch will execute the KVBatch, the provided KVBatch **MUST** have been created by the same KVStore (though not necessarily the same KVWriter) Batch execution is atomic, either all the operations or none will be performed

func (Writer) NewBatch

func (w Writer) NewBatch() store.KVBatch

NewBatch returns a KVBatch for performing batch operations on this kvstore

func (Writer) NewBatchEx

func (w Writer) NewBatchEx(store.KVBatchOptions) ([]byte, store.KVBatch, error)

NewBatchEx returns a KVBatch and an associated byte array that's pre-sized based on the KVBatchOptions. The caller can use the returned byte array for keys and values associated with the batch. Once the batch is either executed or closed, the associated byte array should no longer be accessed by the caller.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL