redis

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package redis is a facade in front of github.com/go-redis/redis/v8

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTTL defines a default TTL value for all keys.
	DefaultTTL time.Duration

	// Namespace allows for a custom Namespace to be added to all keys.
	Namespace = ""

	// ErrNotFound is returned when no data was found
	ErrNotFound = errors.New("not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	RDB *redis.Client
	// contains filtered or unexported fields
}

Client provides interaction with redis.

func New

func New(server string, requestTimeout time.Duration, clientName string) *Client

New creates a new client.

func (*Client) Delete

func (c *Client) Delete(r metrics.Recorder, key string) error

Delete removes the value at `key`

func (*Client) ForeverTTL added in v1.0.64

func (c *Client) ForeverTTL() int

ForeverTTL returns the redis value that represents the no-expire TTL value.

func (*Client) Get

func (c *Client) Get(r metrics.Recorder, key string) (interface{}, error)

Get returns the value at `key`

func (*Client) GetHashSet

func (c *Client) GetHashSet(r metrics.Recorder, keys []string) ([]map[string]string, error)

GetHashSet uses a redis pipe to retrieve a number of hashes and return an aggregate of their responses.

func (*Client) IncrementHash

func (c *Client) IncrementHash(r metrics.Recorder, key, field string, amount int) error

IncrementHash increments a value at a give key/field location. Hash will live for the standard ttl duration.

func (*Client) IncrementHashWithDuration

func (c *Client) IncrementHashWithDuration(r metrics.Recorder, key, field string, amount int, ttl time.Duration) error

IncrementHashWithDuration increments a value at a give key/field location.

We can only expire the entire hash. We set a TTL via Expire once only if the hash key has not previously existed. We make the assumption that if it already exists, it's already had an Expire set.

func (*Client) Ping

func (c *Client) Ping(r metrics.Recorder) error

Ping tests the connection to Redis.

func (*Client) Set

func (c *Client) Set(r metrics.Recorder, key string, value interface{}) error

Set stores the value at `key` with the default TTL.

func (*Client) SetWithDuration

func (c *Client) SetWithDuration(r metrics.Recorder, key string, value interface{}, ttl time.Duration) error

SetWithDuration stores the value at `key` with the provided TTL.

func (*Client) TTL

func (c *Client) TTL(r metrics.Recorder, key string) (time.Duration, error)

TTL returns the TTL for the value at `key`

Jump to

Keyboard shortcuts

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