redis

package
v0.0.0-...-5f382f4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(cfg config.Redis) (err error)

Types

type Cli

type Cli interface {
	// Get returns value from redis by `key`.
	Get(key string) ([]byte, error)
	// GetInt returns int values from redis by `key`.
	GetInt(key string) (int, error)
	// GetString returns string values from redis by `key`.
	GetString(key string) string

	// Set sets value to redis by `key` with `ttl`.
	Set(key string, value []byte, ttl time.Duration) error
	// Set sets int value to redis by `key` with `ttl`.
	SetInt(key string, value int, ttl time.Duration) error

	// Del deletes `keys` from redis.
	Del(keys ...string) error

	// TTL returns TTL by the `key`.
	TTL(key string) (time.Duration, error)
	// Expire adds expiration(`exp`) time for `key`.
	Expire(key string, exp time.Duration) error
	// Exists checks if a `key` exists.
	Exists(key string) (bool, error)

	// Ping pings the redis.
	Ping(ctx context.Context) error
}

func GetRedis

func GetRedis() Cli

type Client

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

func (*Client) Del

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

func (*Client) Exists

func (r *Client) Exists(key string) (bool, error)

func (*Client) Expire

func (r *Client) Expire(key string, exp time.Duration) error

func (*Client) Get

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

func (*Client) GetInt

func (r *Client) GetInt(key string) (int, error)

func (*Client) GetString

func (r *Client) GetString(key string) string

func (*Client) Ping

func (r *Client) Ping(ctx context.Context) error

func (*Client) Set

func (r *Client) Set(key string, value []byte, ttl time.Duration) error

func (*Client) SetInt

func (r *Client) SetInt(key string, value int, ttl time.Duration) error

func (*Client) TTL

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

Jump to

Keyboard shortcuts

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