redis

package
v5.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const Nil = redis.Nil

Nil represents the redis nil value

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	ClusterMode() bool
	ClusterCountKeysInSlot(slot int) Result
	ClusterSlotForKey(key string) Result
	ClusterKeysInSlot(slot int, count int) Result
	Del(keys ...string) Result
	Exists(keys ...string) Result
	Get(key string) Result
	Set(key string, value interface{}, expiration time.Duration) Result
	Ping() Result
	Keys(pattern string) Result
	SMembers(key string) Result
	SIsMember(key string, member interface{}) Result
	SAdd(key string, members ...interface{}) Result
	SRem(key string, members ...interface{}) Result
	Incr(key string) Result
	Decr(key string) Result
	RPush(key string, values ...interface{}) Result
	LRange(key string, start, stop int64) Result
	LTrim(key string, start, stop int64) Result
	LLen(key string) Result
	Expire(key string, value time.Duration) Result
	TTL(key string) Result
	MGet(keys []string) Result
	SCard(key string) Result
	Eval(script string, keys []string, args ...interface{}) Result
	HIncrBy(key string, field string, value int64) Result
	HSet(key string, hashKey string, value interface{}) Result
	HGetAll(key string) Result
	Type(key string) Result
	Pipeline() Pipeline
	Scan(cursor uint64, match string, count int64) Result
}

Client interface which specifies the currently used subset of redis operations

func NewClient

func NewClient(options *UniversalOptions) (Client, error)

NewClient returns new client implementation

type ClientImpl

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

ClientImpl wrapps redis client

func (*ClientImpl) ClusterCountKeysInSlot added in v5.0.1

func (c *ClientImpl) ClusterCountKeysInSlot(slot int) Result

ClusterCountKeysInSlot returns the number of keys in slot

func (*ClientImpl) ClusterKeysInSlot added in v5.0.1

func (c *ClientImpl) ClusterKeysInSlot(slot int, count int) Result

ClusterKeysInSlot returns all the keys in the supplied slot

func (*ClientImpl) ClusterMode added in v5.0.1

func (c *ClientImpl) ClusterMode() bool

ClusterMode returns true if the client is running in cluster mode

func (*ClientImpl) ClusterSlotForKey added in v5.0.1

func (c *ClientImpl) ClusterSlotForKey(key string) Result

ClusterSlotForKey returns the slot for the supplied key

func (*ClientImpl) Decr

func (c *ClientImpl) Decr(key string) Result

Decr implements Decr wrapper for redis

func (*ClientImpl) Del

func (c *ClientImpl) Del(keys ...string) Result

Del implements Del wrapper for redis

func (*ClientImpl) Eval

func (c *ClientImpl) Eval(script string, keys []string, args ...interface{}) Result

Eval implements Eval wrapper for redis

func (*ClientImpl) Exists

func (c *ClientImpl) Exists(keys ...string) Result

Exists implements Exists wrapper for redis

func (*ClientImpl) Expire

func (c *ClientImpl) Expire(key string, value time.Duration) Result

Expire implements Expire wrapper for redis

func (*ClientImpl) Get

func (c *ClientImpl) Get(key string) Result

Get implements Get wrapper for redis

func (*ClientImpl) HGetAll

func (c *ClientImpl) HGetAll(key string) Result

HGetAll implements HGetAll wrapper for redis

func (*ClientImpl) HIncrBy

func (c *ClientImpl) HIncrBy(key string, field string, value int64) Result

HIncrBy implements HIncrBy wrapper for redis

func (*ClientImpl) HSet

func (c *ClientImpl) HSet(key string, hashKey string, value interface{}) Result

HSet implements HSet wrapper for redis

func (*ClientImpl) Incr

func (c *ClientImpl) Incr(key string) Result

Incr implements Incr wrapper for redis

func (*ClientImpl) Keys

func (c *ClientImpl) Keys(pattern string) Result

Keys implements Keys wrapper for redis

func (*ClientImpl) LLen

func (c *ClientImpl) LLen(key string) Result

LLen implements LLen wrapper for redis

func (*ClientImpl) LRange

func (c *ClientImpl) LRange(key string, start, stop int64) Result

LRange implements LRange wrapper for redis

func (*ClientImpl) LTrim

func (c *ClientImpl) LTrim(key string, start, stop int64) Result

LTrim implements LTrim wrapper for redis

func (*ClientImpl) MGet

func (c *ClientImpl) MGet(keys []string) Result

MGet implements MGet wrapper for redis

func (*ClientImpl) Ping

func (c *ClientImpl) Ping() Result

Ping implements Ping wrapper for redis

func (*ClientImpl) Pipeline

func (c *ClientImpl) Pipeline() Pipeline

Pipeline implements Pipeline wrapper for redis

func (*ClientImpl) RPush

func (c *ClientImpl) RPush(key string, values ...interface{}) Result

RPush implements RPush wrapper for redis

func (*ClientImpl) SAdd

func (c *ClientImpl) SAdd(key string, members ...interface{}) Result

SAdd implements SAdd wrapper for redis

func (*ClientImpl) SCard

func (c *ClientImpl) SCard(key string) Result

SCard implements SCard wrapper for redis

func (*ClientImpl) SIsMember

func (c *ClientImpl) SIsMember(key string, member interface{}) Result

SIsMember implements SIsMember wrapper for redis

func (*ClientImpl) SMembers

func (c *ClientImpl) SMembers(key string) Result

SMembers implements SMembers wrapper for redis

func (*ClientImpl) SRem

func (c *ClientImpl) SRem(key string, members ...interface{}) Result

SRem implements SRem wrapper for redis

func (*ClientImpl) Scan added in v5.4.0

func (c *ClientImpl) Scan(cursor uint64, match string, count int64) Result

Scan implements Scan wrapper for redis

func (*ClientImpl) Set

func (c *ClientImpl) Set(key string, value interface{}, expiration time.Duration) Result

Set implements Set wrapper for redis

func (*ClientImpl) TTL

func (c *ClientImpl) TTL(key string) Result

TTL implements TTL wrapper for redis

func (*ClientImpl) Type

func (c *ClientImpl) Type(key string) Result

Type implements Type wrapper for redis

type Pipeline

type Pipeline interface {
	LRange(key string, start, stop int64)
	LTrim(key string, start, stop int64)
	LLen(key string)
	HIncrBy(key string, field string, value int64)
	HLen(key string)
	Set(key string, value interface{}, expiration time.Duration)
	Incr(key string)
	Decr(key string)
	SAdd(key string, members ...interface{})
	SRem(key string, members ...interface{})
	SMembers(key string)
	Del(keys ...string)
	Exec() ([]Result, error)
}

Pipeline defines the interface of a redis pipeline

type PipelineImpl

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

PipelineImpl Wrapper

func (*PipelineImpl) Decr added in v5.3.2

func (p *PipelineImpl) Decr(key string)

Decr schedules a Decr operation on this pipeline

func (*PipelineImpl) Del added in v5.3.2

func (p *PipelineImpl) Del(keys ...string)

Del schedules a Del operation on this pipeline

func (*PipelineImpl) Exec

func (p *PipelineImpl) Exec() ([]Result, error)

Exec executes the pipeline

func (*PipelineImpl) HIncrBy added in v5.2.2

func (p *PipelineImpl) HIncrBy(key string, field string, value int64)

HIncrBy schedules an hincrby operation on this pipeline

func (*PipelineImpl) HLen added in v5.2.2

func (p *PipelineImpl) HLen(key string)

HLen schedules an HLen operation on this pipeline

func (*PipelineImpl) Incr added in v5.3.2

func (p *PipelineImpl) Incr(key string)

Incr schedules an Incr operation on this pipeline

func (*PipelineImpl) LLen

func (p *PipelineImpl) LLen(key string)

LLen schedules an llen operation on this pipeline

func (*PipelineImpl) LRange

func (p *PipelineImpl) LRange(key string, start, stop int64)

LRange schedules an lrange operation on this pipeline

func (*PipelineImpl) LTrim

func (p *PipelineImpl) LTrim(key string, start, stop int64)

LTrim schedules an ltrim operation on this pipeline

func (*PipelineImpl) SAdd added in v5.3.2

func (p *PipelineImpl) SAdd(key string, members ...interface{})

SAdd schedules a SAdd operation on this pipeline

func (*PipelineImpl) SMembers added in v5.3.2

func (p *PipelineImpl) SMembers(key string)

SMembers schedules a SMembers operation on this pipeline

func (*PipelineImpl) SRem added in v5.3.2

func (p *PipelineImpl) SRem(key string, members ...interface{})

SRem schedules a SRem operation on this pipeline

func (*PipelineImpl) Set added in v5.3.2

func (p *PipelineImpl) Set(key string, value interface{}, expiration time.Duration)

Set schedules a Set operation on this pipeline

type PrefixedPipeline

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

PrefixedPipeline adds a prefix to all pipelined operations involving keys

func (*PrefixedPipeline) Decr added in v5.3.2

func (p *PrefixedPipeline) Decr(key string)

Decr schedules a Decr operation on this pipeline

func (*PrefixedPipeline) Del added in v5.3.2

func (p *PrefixedPipeline) Del(keys ...string)

Del schedules a Del operation on this pipeline

func (*PrefixedPipeline) Exec

func (p *PrefixedPipeline) Exec() ([]Result, error)

Exec executes the pipeline

func (*PrefixedPipeline) HIncrBy added in v5.2.2

func (p *PrefixedPipeline) HIncrBy(key string, field string, value int64)

HIncrBy schedules an hincrby operation on this pipeline

func (*PrefixedPipeline) HLen added in v5.2.2

func (p *PrefixedPipeline) HLen(key string)

HLen schedules an HLen operation on this pipeline

func (*PrefixedPipeline) Incr added in v5.3.2

func (p *PrefixedPipeline) Incr(key string)

Incr schedules an Incr operation on this pipeline

func (*PrefixedPipeline) LLen

func (p *PrefixedPipeline) LLen(key string)

LLen schedules an llen operation on this pipeline

func (*PrefixedPipeline) LRange

func (p *PrefixedPipeline) LRange(key string, start, stop int64)

LRange schedules an lrange operation on this pipeline

func (*PrefixedPipeline) LTrim

func (p *PrefixedPipeline) LTrim(key string, start, stop int64)

LTrim schedules an ltrim operation on this pipeline

func (*PrefixedPipeline) SAdd added in v5.3.2

func (p *PrefixedPipeline) SAdd(key string, members ...interface{})

SAdd schedules a SAdd operation on this pipeline

func (*PrefixedPipeline) SMembers added in v5.3.2

func (p *PrefixedPipeline) SMembers(key string)

SMembers schedules a SMembers operation on this pipeline

func (*PrefixedPipeline) SRem added in v5.3.2

func (p *PrefixedPipeline) SRem(key string, members ...interface{})

SRem schedules a SRem operation on this pipeline

func (*PrefixedPipeline) Set added in v5.3.2

func (p *PrefixedPipeline) Set(key string, value interface{}, expiration time.Duration)

Set schedules a Set operation on this pipeline

type PrefixedRedisClient

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

PrefixedRedisClient struct

func NewPrefixedRedisClient

func NewPrefixedRedisClient(redisClient Client, prefix string) (*PrefixedRedisClient, error)

NewPrefixedRedisClient returns a new Prefixed Redis Client

func (*PrefixedRedisClient) ClusterCountKeysInSlot added in v5.0.1

func (p *PrefixedRedisClient) ClusterCountKeysInSlot(slot int) (int64, error)

ClusterCountKeysInSlot returns the number of keys in slot

func (*PrefixedRedisClient) ClusterKeysInSlot added in v5.0.1

func (p *PrefixedRedisClient) ClusterKeysInSlot(slot int, count int) ([]string, error)

ClusterKeysInSlot returns all the keys in the supplied slot

func (*PrefixedRedisClient) ClusterMode added in v5.0.1

func (p *PrefixedRedisClient) ClusterMode() bool

ClusterMode returns true if the client is working in cluster mode

func (*PrefixedRedisClient) ClusterSlotForKey added in v5.0.1

func (p *PrefixedRedisClient) ClusterSlotForKey(key string) (int64, error)

ClusterSlotForKey returns the slot for the supplied key

func (*PrefixedRedisClient) Decr

func (p *PrefixedRedisClient) Decr(key string) (int64, error)

Decr increments a key. Sets it in one if it doesn't exist

func (*PrefixedRedisClient) Del

func (p *PrefixedRedisClient) Del(keys ...string) (int64, error)

Del wraps around redis del method by adding prefix and returning int64 and error directly

func (*PrefixedRedisClient) Eval

func (p *PrefixedRedisClient) Eval(script string, keys []string, args ...interface{}) error

Eval implements Eval wrapper for redis

func (*PrefixedRedisClient) Exists

func (p *PrefixedRedisClient) Exists(keys ...string) (int64, error)

Exists returns true if a key exists in redis

func (*PrefixedRedisClient) Expire

func (p *PrefixedRedisClient) Expire(key string, value time.Duration) bool

Expire set expiration time for particular key

func (*PrefixedRedisClient) Get

func (p *PrefixedRedisClient) Get(key string) (string, error)

Get wraps around redis get method by adding prefix and returning string and error directly

func (*PrefixedRedisClient) HGetAll

func (p *PrefixedRedisClient) HGetAll(key string) (map[string]string, error)

HGetAll implements HGetAll wrapper for redis

func (*PrefixedRedisClient) HIncrBy

func (p *PrefixedRedisClient) HIncrBy(key string, field string, value int64) (int64, error)

HIncrBy implements HIncrBy wrapper for redis

func (*PrefixedRedisClient) HSet

func (p *PrefixedRedisClient) HSet(key string, hashKey string, value interface{}) error

HSet implements HGetAll wrapper for redis

func (*PrefixedRedisClient) Incr

func (p *PrefixedRedisClient) Incr(key string) (int64, error)

Incr increments a key. Sets it in one if it doesn't exist

func (*PrefixedRedisClient) Keys

func (p *PrefixedRedisClient) Keys(pattern string) ([]string, error)

Keys wraps around redis keys method by adding prefix and returning []string and error directly

func (*PrefixedRedisClient) LLen

func (p *PrefixedRedisClient) LLen(key string) (int64, error)

LLen Returns the length of the list stored at key

func (*PrefixedRedisClient) LRange

func (p *PrefixedRedisClient) LRange(key string, start, stop int64) ([]string, error)

LRange Returns the specified elements of the list stored at key

func (*PrefixedRedisClient) LTrim

func (p *PrefixedRedisClient) LTrim(key string, start, stop int64) error

LTrim Trim an existing list so that it will contain only the specified range of elements specified

func (*PrefixedRedisClient) MGet

func (p *PrefixedRedisClient) MGet(keys []string) ([]interface{}, error)

MGet fetchs multiple results

func (*PrefixedRedisClient) Pipeline

func (p *PrefixedRedisClient) Pipeline() Pipeline

Pipeline wrapper

func (*PrefixedRedisClient) Prefix

func (p *PrefixedRedisClient) Prefix() string

Prefix returns the prefix attached to the client

func (*PrefixedRedisClient) RPush

func (p *PrefixedRedisClient) RPush(key string, values ...interface{}) (int64, error)

RPush insert all the specified values at the tail of the list stored at key

func (*PrefixedRedisClient) SAdd

func (p *PrefixedRedisClient) SAdd(key string, members ...interface{}) (int64, error)

SAdd adds new members to a set

func (*PrefixedRedisClient) SCard

func (p *PrefixedRedisClient) SCard(key string) (int64, error)

SCard implements SCard wrapper for redis

func (*PrefixedRedisClient) SIsMember

func (p *PrefixedRedisClient) SIsMember(key string, member interface{}) bool

SIsMember returns true if members is in the set

func (*PrefixedRedisClient) SMembers

func (p *PrefixedRedisClient) SMembers(key string) ([]string, error)

SMembers returns a slice with all the members of a set

func (*PrefixedRedisClient) SRem

func (p *PrefixedRedisClient) SRem(key string, members ...interface{}) (int64, error)

SRem removes members from a set

func (*PrefixedRedisClient) Scan added in v5.4.0

func (p *PrefixedRedisClient) Scan(cursor uint64, match string, count int64) ([]string, uint64, error)

func (*PrefixedRedisClient) Set

func (p *PrefixedRedisClient) Set(key string, value interface{}, expiration time.Duration) error

Set wraps around redis get method by adding prefix and returning error directly

func (*PrefixedRedisClient) TTL

TTL for particular key

func (*PrefixedRedisClient) Type

func (p *PrefixedRedisClient) Type(key string) (string, error)

Type implements Type wrapper for redis with prefix

type Result

type Result interface {
	Int() int64
	String() string
	Bool() bool
	Duration() time.Duration
	Result() (int64, error)
	ResultString() (string, error)
	Multi() ([]string, error)
	MultiInterface() ([]interface{}, error)
	Err() error
	MapStringString() (map[string]string, error)
}

Result generic interface

type ResultImpl

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

ResultImpl generic interface

func (*ResultImpl) Bool

func (r *ResultImpl) Bool() bool

Bool implementation

func (*ResultImpl) Duration

func (r *ResultImpl) Duration() time.Duration

Duration implementation

func (*ResultImpl) Err

func (r *ResultImpl) Err() error

Err implementation

func (*ResultImpl) Int

func (r *ResultImpl) Int() int64

Int implementation

func (*ResultImpl) MapStringString

func (r *ResultImpl) MapStringString() (map[string]string, error)

MapStringString implementation

func (*ResultImpl) Multi

func (r *ResultImpl) Multi() ([]string, error)

Multi implementation

func (*ResultImpl) MultiInterface

func (r *ResultImpl) MultiInterface() ([]interface{}, error)

MultiInterface implementation

func (*ResultImpl) Result

func (r *ResultImpl) Result() (int64, error)

Result implementation

func (*ResultImpl) ResultString

func (r *ResultImpl) ResultString() (string, error)

ResultString implementation

func (*ResultImpl) String

func (r *ResultImpl) String() string

String implementation

type UniversalOptions

type UniversalOptions struct {

	// Original go-redis.UniversalOptions properties
	Addrs              []string
	DB                 int
	Dialer             func(ctx context.Context, network, addr string) (net.Conn, error)
	OnConnect          func(ctx context.Context, cn *wredis.Conn) error
	Username           string
	Password           string
	SentinelPassword   string
	MaxRetries         int
	MinRetryBackoff    time.Duration
	MaxRetryBackoff    time.Duration
	DialTimeout        time.Duration
	ReadTimeout        time.Duration
	WriteTimeout       time.Duration
	PoolSize           int
	MinIdleConns       int
	MaxConnAge         time.Duration
	PoolTimeout        time.Duration
	IdleTimeout        time.Duration
	IdleCheckFrequency time.Duration
	TLSConfig          *tls.Config
	MaxRedirects       int
	ReadOnly           bool
	RouteByLatency     bool
	RouteRandomly      bool
	MasterName         string

	// Custom properties
	ForceClusterMode bool
}

UniversalOptions type used for redis package TODO(mredolatti): In order to avoid breaking the API, the struct now contains all original fields of go-redis' UniversalOptions struct, with our custom ones. Next time we bump toolkit's version, we should instead wrap or embed the original struct as well.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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