redis

package
v2.3.1-beta.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PluginName = "redis"

Variables

This section is empty.

Functions

func NewPubSubDriver added in v2.3.1

func NewPubSubDriver(log logger.Logger, key string, cfgPlugin config.Configurer, stopCh chan struct{}) (pubsub.PubSub, error)

func NewRedisDriver added in v2.3.1

func NewRedisDriver(log logger.Logger, key string, cfgPlugin config.Configurer) (kv.Storage, error)

Types

type Config

type Config struct {
	Addrs            []string      `mapstructure:"addrs"`
	DB               int           `mapstructure:"db"`
	Username         string        `mapstructure:"username"`
	Password         string        `mapstructure:"password"`
	MasterName       string        `mapstructure:"master_name"`
	SentinelPassword string        `mapstructure:"sentinel_password"`
	RouteByLatency   bool          `mapstructure:"route_by_latency"`
	RouteRandomly    bool          `mapstructure:"route_randomly"`
	MaxRetries       int           `mapstructure:"max_retries"`
	DialTimeout      time.Duration `mapstructure:"dial_timeout"`
	MinRetryBackoff  time.Duration `mapstructure:"min_retry_backoff"`
	MaxRetryBackoff  time.Duration `mapstructure:"max_retry_backoff"`
	PoolSize         int           `mapstructure:"pool_size"`
	MinIdleConns     int           `mapstructure:"min_idle_conns"`
	MaxConnAge       time.Duration `mapstructure:"max_conn_age"`
	ReadTimeout      time.Duration `mapstructure:"read_timeout"`
	WriteTimeout     time.Duration `mapstructure:"write_timeout"`
	PoolTimeout      time.Duration `mapstructure:"pool_timeout"`
	IdleTimeout      time.Duration `mapstructure:"idle_timeout"`
	IdleCheckFreq    time.Duration `mapstructure:"idle_check_freq"`
	ReadOnly         bool          `mapstructure:"read_only"`
}

func (*Config) InitDefaults

func (s *Config) InitDefaults()

InitDefaults initializing fill config with default values

type Driver added in v2.3.1

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

func (*Driver) Delete added in v2.3.1

func (d *Driver) Delete(keys ...string) error

Delete one or multiple keys.

func (*Driver) Get added in v2.3.1

func (d *Driver) Get(key string) ([]byte, error)

Get loads key content into slice.

func (*Driver) Has added in v2.3.1

func (d *Driver) Has(keys ...string) (map[string]bool, error)

Has checks if value exists.

func (*Driver) MExpire added in v2.3.1

func (d *Driver) MExpire(items ...*kvv1.Item) error

MExpire https://redis.io/commands/expire timeout in RFC3339

func (*Driver) MGet added in v2.3.1

func (d *Driver) MGet(keys ...string) (map[string][]byte, error)

MGet loads content of multiple values (some values might be skipped). https://redis.io/commands/mget Returns slice with the interfaces with values

func (*Driver) Set added in v2.3.1

func (d *Driver) Set(items ...*kvv1.Item) error

Set sets value with the TTL in seconds https://redis.io/commands/set Redis `SET key value [expiration]` command.

Use expiration for `SETEX`-like behavior. Zero expiration means the key has no expiration time.

func (*Driver) TTL added in v2.3.1

func (d *Driver) TTL(keys ...string) (map[string]string, error)

TTL https://redis.io/commands/ttl return time in seconds (float64) for a given keys

type Plugin

type Plugin struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Plugin) Available added in v2.2.0

func (p *Plugin) Available()

Available interface implementation

func (*Plugin) DefaultClient added in v2.3.1

func (p *Plugin) DefaultClient() redis.UniversalClient

func (*Plugin) Init

func (p *Plugin) Init(cfg config.Configurer, log logger.Logger) error

func (*Plugin) KVConstruct added in v2.3.1

func (p *Plugin) KVConstruct(key string) (kv.Storage, error)

KVConstruct provides KV storage implementation over the redis plugin

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) PSConstruct added in v2.3.1

func (p *Plugin) PSConstruct(key string) (pubsub.PubSub, error)

func (*Plugin) RedisClient added in v2.3.1

func (p *Plugin) RedisClient(key string) (redis.UniversalClient, error)

RedisClient return a client based on the provided section key key sample: kv.some-section.redis kv.redis redis (root)

func (*Plugin) Serve

func (p *Plugin) Serve() chan error

func (*Plugin) Stop

func (p *Plugin) Stop() error

type PubSubDriver added in v2.3.1

type PubSubDriver struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*PubSubDriver) Connections added in v2.3.1

func (p *PubSubDriver) Connections(topic string, res map[string]struct{})

func (*PubSubDriver) Next added in v2.3.1

func (p *PubSubDriver) Next() (*pubsub.Message, error)

Next return next message

func (*PubSubDriver) Publish added in v2.3.1

func (p *PubSubDriver) Publish(msg *pubsub.Message) error

func (*PubSubDriver) PublishAsync added in v2.3.1

func (p *PubSubDriver) PublishAsync(msg *pubsub.Message)

func (*PubSubDriver) Subscribe added in v2.3.1

func (p *PubSubDriver) Subscribe(connectionID string, topics ...string) error

func (*PubSubDriver) Unsubscribe added in v2.3.1

func (p *PubSubDriver) Unsubscribe(connectionID string, topics ...string) error

type Redis

type Redis interface {
	// RedisClient provides universal redis client
	RedisClient(key string) (redis.UniversalClient, error)

	// DefaultClient provide default redis client based on redis defaults
	DefaultClient() redis.UniversalClient
}

Redis in the redis KV plugin interface

Jump to

Keyboard shortcuts

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