redis

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package redis implements the storage.Backend interface for redis.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExceededMaxRetries = errors.New("redis: transaction reached maximum number of retries")
)

custom errors

Functions

This section is empty.

Types

type Backend added in v0.14.0

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

Backend implements the storage.Backend on top of redis.

What's stored:

  • last_version: an integer recordVersion number
  • last_version_ch: a PubSub channel for recordVersion number updates
  • records: a Hash of records. The hash key is {recordType}/{recordID}, the hash value the protobuf record.
  • changes: a Sorted Set of all the changes. The score is the recordVersion number, the member the protobuf record.
  • options: a Hash of options. The hash key is {recordType}, the hash value the protobuf options.
  • changes.{recordType}: a Sorted Set of the changes for a record type. The score is the current time, the value the record id.

Records stored in these keys are typically encrypted.

func New

func New(rawURL string, options ...Option) (*Backend, error)

New creates a new redis storage backend.

func (*Backend) Close added in v0.14.0

func (backend *Backend) Close() error

Close closes the underlying redis connection and any watchers.

func (*Backend) Get added in v0.14.0

func (backend *Backend) Get(ctx context.Context, recordType, id string) (_ *databroker.Record, err error)

Get gets a record from redis.

func (*Backend) GetOptions added in v0.14.0

func (backend *Backend) GetOptions(ctx context.Context, recordType string) (*databroker.Options, error)

GetOptions gets the options for the given record type.

func (*Backend) Lease added in v0.15.0

func (backend *Backend) Lease(ctx context.Context, leaseName, leaseID string, ttl time.Duration) (bool, error)

Lease acquires or renews a lease.

func (*Backend) ListTypes added in v0.22.0

func (backend *Backend) ListTypes(ctx context.Context) (types []string, err error)

ListTypes lists all the known record types.

func (*Backend) Put added in v0.14.0

func (backend *Backend) Put(ctx context.Context, records []*databroker.Record) (serverVersion uint64, err error)

Put puts a record into redis.

func (*Backend) SetOptions added in v0.14.0

func (backend *Backend) SetOptions(ctx context.Context, recordType string, options *databroker.Options) error

SetOptions sets the options for the given record type.

func (*Backend) Sync added in v0.14.0

func (backend *Backend) Sync(
	ctx context.Context,
	recordType string,
	serverVersion, recordVersion uint64,
) (storage.RecordStream, error)

Sync returns a record stream of any records changed after the specified recordVersion.

func (*Backend) SyncLatest added in v0.17.3

func (backend *Backend) SyncLatest(
	ctx context.Context,
	recordType string,
	expr storage.FilterExpression,
) (serverVersion, recordVersion uint64, stream storage.RecordStream, err error)

SyncLatest returns a record stream of all the records. Some records may be returned twice if the are updated while the stream is streaming.

type Option

type Option func(*config)

Option customizes a Backend.

func WithExpiry added in v0.14.0

func WithExpiry(expiry time.Duration) Option

WithExpiry sets the expiry for changes.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig sets the tls.Config which Backend uses.

Jump to

Keyboard shortcuts

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