Documentation ¶
Overview ¶
Package redis implements the storage.Backend interface for redis.
Index ¶
- Variables
- type Backend
- func (backend *Backend) Close() error
- func (backend *Backend) Get(ctx context.Context, recordType, id string) (_ *databroker.Record, err error)
- func (backend *Backend) GetAll(ctx context.Context) (records []*databroker.Record, versions *databroker.Versions, err error)
- func (backend *Backend) GetOptions(ctx context.Context, recordType string) (*databroker.Options, error)
- func (backend *Backend) Lease(ctx context.Context, leaseName, leaseID string, ttl time.Duration) (bool, error)
- func (backend *Backend) Put(ctx context.Context, record *databroker.Record) (serverVersion uint64, err error)
- func (backend *Backend) SetOptions(ctx context.Context, recordType string, options *databroker.Options) error
- func (backend *Backend) Sync(ctx context.Context, serverVersion, recordVersion uint64) (storage.RecordStream, error)
- type Option
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 (*Backend) Close ¶ added in v0.14.0
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) GetAll ¶ added in v0.14.0
func (backend *Backend) GetAll(ctx context.Context) (records []*databroker.Record, versions *databroker.Versions, err error)
GetAll gets all the records 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) Put ¶ added in v0.14.0
func (backend *Backend) Put(ctx context.Context, record *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.
type Option ¶
type Option func(*config)
Option customizes a Backend.
func WithExpiry ¶ added in v0.14.0
WithExpiry sets the expiry for changes.
func WithTLSConfig ¶
WithTLSConfig sets the tls.Config which Backend uses.
Click to show internal directories.
Click to hide internal directories.