redis

package
v0.11.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package redis is the redis database, implements storage.Backend interface.

Index

Constants

Name is the storage type name for redis backend.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB wraps redis conn to interact with redis server.

func New

func New(rawURL, recordType string, opts ...Option) (*DB, error)

New returns new DB instance.

func (*DB) ClearDeleted

func (db *DB) ClearDeleted(ctx context.Context, cutoff time.Time)

ClearDeleted clears all the currently deleted records older than the given cutoff.

func (*DB) Close added in v0.11.0

func (db *DB) Close() error

Close closes the redis db connection.

func (*DB) Delete

func (db *DB) Delete(ctx context.Context, id string) (err error)

Delete sets a record DeletedAt field and set its TTL.

func (*DB) Get

func (db *DB) Get(ctx context.Context, id string) (rec *databroker.Record, err error)

Get retrieves a record from redis.

func (*DB) GetAll

func (db *DB) GetAll(ctx context.Context) (recs []*databroker.Record, err error)

GetAll retrieves all records from redis.

func (*DB) List

func (db *DB) List(ctx context.Context, sinceVersion string) (rec []*databroker.Record, err error)

List retrieves all records since given version.

"version" is in hex format, invalid version will be treated as 0.

func (*DB) Put

func (db *DB) Put(ctx context.Context, id string, data *anypb.Any) (err error)

Put sets new record for given id with input data.

func (*DB) Watch

func (db *DB) Watch(ctx context.Context) <-chan struct{}

Watch returns a channel to the caller, when there is a change to the version set, sending message to the channel to notify the caller.

type Option

type Option func(*DB)

Option customizes a DB.

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) Option

WithTLSConfig sets the tls.Config which DB uses.

Jump to

Keyboard shortcuts

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