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) 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, records []*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, recordType string, serverVersion, recordVersion uint64) (storage.RecordStream, error)
- func (backend *Backend) SyncLatest(ctx context.Context, recordType string, expr storage.FilterExpression) (serverVersion, recordVersion uint64, stream storage.RecordStream, err error)
- type Option
Constants ¶
This section is empty.
Variables ¶
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) 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, 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
WithExpiry sets the expiry for changes.
func WithTLSConfig ¶
WithTLSConfig sets the tls.Config which Backend uses.