kv

package
v4.4.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 Configurer

type Configurer interface {
	// UnmarshalKey takes a single key and unmarshal it into a Struct.
	UnmarshalKey(name string, out any) error
	// Has checks if config section exists.
	Has(name string) bool
}

type Driver

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

func NewRedisDriver

func NewRedisDriver(log *zap.Logger, key string, cfgPlugin Configurer, tracer *sdktrace.TracerProvider) (*Driver, error)

func (*Driver) Clear

func (d *Driver) Clear() error

func (*Driver) Delete

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

Delete one or multiple keys.

func (*Driver) Get

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

Get loads key content into slice.

func (*Driver) Has

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

Has checks if value exists.

func (*Driver) MExpire

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

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

func (*Driver) MGet

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

func (d *Driver) Set(items ...kv.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) Stop

func (d *Driver) Stop()

func (*Driver) TTL

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

Jump to

Keyboard shortcuts

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