redis

package
v0.0.0-...-c537d22 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIterationLimit = 50
)

Variables

View Source
var (
	ErrNotOk    = errors.New("not ok")
	ErrBadReply = errors.New("bad reply")
	ErrNoPool   = errors.New("no connection pool")
)
View Source
var (
	ErrInvalidCacheKey = errors.New("invalid cache key")
)

Functions

This section is empty.

Types

type Cache

type Cache struct {
	Redis *Redis
	// contains filtered or unexported fields
}

func NewCache

func NewCache(connURL string) (*Cache, error)

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Del

func (c *Cache) Del(keys ...string) error

func (*Cache) DeleteKeyMatch

func (c *Cache) DeleteKeyMatch(match string) (int, error)

func (*Cache) Get

func (c *Cache) Get(key string) (string, bool, error)

func (*Cache) Search

func (c *Cache) Search(match string, cursor, limit int) ([]string, int, error)

func (*Cache) SearchMaxIter

func (c *Cache) SearchMaxIter(match string, cursor, limit int, maxIter int) ([]string, int, error)

func (*Cache) Set

func (c *Cache) Set(key, value string, expire time.Duration) error

func (*Cache) WipeLocal

func (c *Cache) WipeLocal()

type DeleteErrors

type DeleteErrors struct {
	Errors map[string]error
}

func (*DeleteErrors) Add

func (e *DeleteErrors) Add(key string, err error)

func (*DeleteErrors) Error

func (e *DeleteErrors) Error() string

type Redis

type Redis struct {
	ConnURL string
	Pool    *gore.Pool
}

func NewRedis

func NewRedis(connURL string) (*Redis, error)

Creates a new connection via URL string and authenticates it for you

func (*Redis) Close

func (r *Redis) Close()

func (*Redis) Del

func (r *Redis) Del(keys ...string) error

func (*Redis) DeleteKeyMatch

func (r *Redis) DeleteKeyMatch(match string) (int, error)

func (*Redis) DeleteKeyMatchFn

func (r *Redis) DeleteKeyMatchFn(match string, keyFn func(string)) (int, error)

func (*Redis) Get

func (r *Redis) Get(key string) ([]byte, bool, error)

func (*Redis) Keys

func (r *Redis) Keys(match string) ([]string, error)

Yes, all keys in Redis are strings

func (*Redis) RunCmd

func (r *Redis) RunCmd(command string, args ...interface{}) (*gore.Reply, error)

func (*Redis) Scan

func (r *Redis) Scan(cursor int, match string) (xs []string, newCursor int, err error)

func (*Redis) ScanAtLeast

func (r *Redis) ScanAtLeast(match string, cursor, limit int) ([]string, int, error)

ScanAtLeast will scan until the first cursor that the limit is reached. It will return the found keys at that limit.

func (*Redis) ScanAtLeastWithMaxIter

func (r *Redis) ScanAtLeastWithMaxIter(match string, cursor, limit int, maxIter int) ([]string, int, error)

ScanAtLeastWithMaxIter tries to scan at least a certain amount of records, but will stop with the max number of empty scans reaches a certain point.

func (*Redis) ScanIterate

func (r *Redis) ScanIterate(match string, cursor int, consumer func([]string) bool) (int, error)

func (*Redis) Set

func (r *Redis) Set(key string, value interface{}, expire time.Duration) error

NOTICE: https://redis.io/commands/set Since the SET command options can replace SETNX, SETEX, PSETEX, GETSET, it is possible that in future versions of Redis these three commands will be deprecated and finally removed.

Hence, let's not implement them. - Tom

Jump to

Keyboard shortcuts

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