redis

package
v3.4.30+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RedisPort = 6379

RedisPort is the default port for talking to Redis

Variables

This section is empty.

Functions

func IsRunning

func IsRunning() bool

IsRunning provides a quick check to see if Redis is already running

func NewConnector

func NewConnector(config Config, scope metrics.Scope) dosa.Connector

NewConnector initializes a Redis Connector

Types

type Config

type Config struct {
	// ServerSettings are the settings specific to redis server
	ServerSettings ServerConfig
	// TTL for how long values should live in the cache
	TTL time.Duration
	// KeyPrefix is used as the prefix to construct redis key
	KeyPrefix string
}

Config holds the settings for a RedisConnector

type Connector

type Connector struct {
	base.Connector
	// contains filtered or unexported fields
}

Connector for redis database

func (*Connector) CreateIfNotExists

func (c *Connector) CreateIfNotExists(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error

CreateIfNotExists not implemented

func (*Connector) MultiRead

func (c *Connector) MultiRead(ctx context.Context, ei *dosa.EntityInfo, keys []map[string]dosa.FieldValue, minimumFields []string) (results []*dosa.FieldValuesOrError, err error)

MultiRead not implemented

func (*Connector) MultiRemove

func (c *Connector) MultiRemove(ctx context.Context, ei *dosa.EntityInfo, multiKeys []map[string]dosa.FieldValue) (result []error, err error)

MultiRemove not implemented

func (*Connector) MultiUpsert

func (c *Connector) MultiUpsert(ctx context.Context, ei *dosa.EntityInfo, multiValues []map[string]dosa.FieldValue) (result []error, err error)

MultiUpsert not implemented

func (*Connector) Range

func (c *Connector) Range(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition, minimumFields []string, token string, limit int) ([]map[string]dosa.FieldValue, string, error)

Range not implemented.

func (*Connector) Read

func (c *Connector) Read(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue, fieldsToRead []string) (map[string]dosa.FieldValue, error)

Read reads an object based on primary key

func (*Connector) Remove

func (c *Connector) Remove(ctx context.Context, ei *dosa.EntityInfo, keys map[string]dosa.FieldValue) error

Remove deletes a key

func (*Connector) RemoveRange

func (c *Connector) RemoveRange(ctx context.Context, ei *dosa.EntityInfo, columnConditions map[string][]*dosa.Condition) error

RemoveRange not implemented

func (*Connector) Scan

func (c *Connector) Scan(ctx context.Context, ei *dosa.EntityInfo, minimumFields []string, token string, limit int) (multiValues []map[string]dosa.FieldValue, nextToken string, err error)

Scan not implemented.

func (*Connector) Shutdown

func (c *Connector) Shutdown() error

Shutdown not implemented

func (*Connector) Upsert

func (c *Connector) Upsert(ctx context.Context, ei *dosa.EntityInfo, values map[string]dosa.FieldValue) error

Upsert means update an existing object or create a new object

type ErrInvalidEntity

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

ErrInvalidEntity is returned for dosa entities that cannot be categorized as a key-value schema for redis

func NewErrInvalidEntity

func NewErrInvalidEntity(msg string) *ErrInvalidEntity

NewErrInvalidEntity returns an ErrInvalidEntity

func (*ErrInvalidEntity) Error

func (e *ErrInvalidEntity) Error() string

Error returns why the schema does not conform to key-value format

type ErrNotImplemented

type ErrNotImplemented struct{}

ErrNotImplemented is returned for interface methods that do not have an implementation

func (*ErrNotImplemented) Error

func (*ErrNotImplemented) Error() string

Error returns a constant string "Not implemented"

type ServerConfig

type ServerConfig struct {
	Host string
	Port int
	// MaxIdle is the maximum number of idle connections in the pool.
	MaxIdle int
	// IdleTimeout directs to close connections after remaining idle for this duration.
	// If the value is zero, then idle connections are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	IdleTimeout time.Duration
	// Maximum number of connections allocated by the pool at a given time.
	// When zero, there is no limit on the number of connections in the pool.
	MaxActive int

	ConnectTimeout time.Duration
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

ServerConfig holds the settings for redis

type SimpleRedis

type SimpleRedis interface {
	Get(key string) ([]byte, error)
	SetEx(key string, value []byte, ttl time.Duration) error
	Del(key string) error
	Shutdown() error
}

SimpleRedis is a minimal interface to Redis commands

func NewRedigoClient

func NewRedigoClient(config ServerConfig, scope metrics.Scope) SimpleRedis

NewRedigoClient returns a redigo implementation of SimpleRedis

Jump to

Keyboard shortcuts

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