redis

package
v1.94.2 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error is a redis error.
	Error = errs.Class("redis")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	TTL time.Duration
	// contains filtered or unexported fields
}

Client is the entrypoint into Redis.

func OpenClient

func OpenClient(ctx context.Context, address, password string, db int) (*Client, error)

OpenClient returns a configured Client instance, verifying a successful connection to redis.

func OpenClientFrom

func OpenClientFrom(ctx context.Context, address string) (*Client, error)

OpenClientFrom returns a configured Client instance from a redis address, verifying a successful connection to redis.

func (*Client) Close

func (client *Client) Close() error

Close closes a redis client.

func (*Client) Delete

func (client *Client) Delete(ctx context.Context, key kvstore.Key) (err error)

Delete deletes a key/value pair from redis, for a given the key.

func (*Client) Eval

func (client *Client) Eval(ctx context.Context, script string, keys []string) (err error)

Eval evaluates a Lua 5.1 script on Redis Server. This arguments can be accessed by Lua using the KEYS global variable in the form of a one-based array (so KEYS[1], KEYS[2], ...).

func (*Client) FlushDB

func (client *Client) FlushDB(ctx context.Context) error

FlushDB deletes all keys in the currently selected DB.

func (*Client) Get

func (client *Client) Get(ctx context.Context, key kvstore.Key) (_ kvstore.Value, err error)

Get looks up the provided key from redis returning either an error or the result.

func (*Client) IncrBy

func (client *Client) IncrBy(ctx context.Context, key kvstore.Key, value int64) (err error)

IncrBy increments the value stored in key by the specified value.

func (*Client) Put

func (client *Client) Put(ctx context.Context, key kvstore.Key, value kvstore.Value) (err error)

Put adds a value to the provided key in redis, returning an error on failure.

func (*Client) Range

func (client *Client) Range(ctx context.Context, fn func(context.Context, kvstore.Key, kvstore.Value) error) (err error)

Range iterates over all items in unspecified order.

Jump to

Keyboard shortcuts

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