redigo

package
v0.0.0-...-d22e7c3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxActive int
	MaxIdle   int
	Timeout   int
}

Config of connection

type Redigo

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

Redigo redis

func New

func New(ctx context.Context, address string, config *Config) (*Redigo, error)

New redis connection using redigo library

func (*Redigo) Close

func (rdg *Redigo) Close() error

Close all redis connection

func (*Redigo) Delete

func (rdg *Redigo) Delete(ctx context.Context, key string) (int, error)

Delete key

func (*Redigo) Expire

func (rdg *Redigo) Expire(ctx context.Context, key string, duration int) (int, error)

Expire to set TTL to key

func (*Redigo) Get

func (rdg *Redigo) Get(ctx context.Context, key string) (string, error)

Get string value

func (*Redigo) HDel

func (rdg *Redigo) HDel(ctx context.Context, key string, fields ...string) (int, error)

HDel fields of a key

func (*Redigo) HGet

func (rdg *Redigo) HGet(ctx context.Context, key, field string) (string, error)

HGet key and value

func (*Redigo) HGetAll

func (rdg *Redigo) HGetAll(ctx context.Context, key string) (map[string]string, error)

HGetAll key and value

func (*Redigo) HMGet

func (rdg *Redigo) HMGet(ctx context.Context, key string, fields ...string) ([]string, error)

HMGet keys and value

func (*Redigo) HMSet

func (rdg *Redigo) HMSet(ctx context.Context, key string, kv map[string]interface{}) (string, error)

HMSet function please use basic types only (no struct, array, or map) for kv value

func (*Redigo) HSet

func (rdg *Redigo) HSet(ctx context.Context, key, field string, value interface{}) (int, error)

HSet field and value based on key

func (*Redigo) HSetEX

func (rdg *Redigo) HSetEX(ctx context.Context, key, field string, value interface{}, expire int) (int, error)

HSetEX key and value and sets the expiration to the given `expire` seconds

func (*Redigo) Increment

func (rdg *Redigo) Increment(ctx context.Context, key string) (int, error)

Increment key

func (*Redigo) IncrementBy

func (rdg *Redigo) IncrementBy(ctx context.Context, key string, amount int) (int, error)

IncrementBy key

func (*Redigo) IsErrNil

func (rdg *Redigo) IsErrNil(err error) bool

IsErrNil return true if error is nil

func (*Redigo) IsResponseOK

func (rdg *Redigo) IsResponseOK(result string) bool

IsResponseOK return true if result value of command is ok

func (*Redigo) LIndex

func (rdg *Redigo) LIndex(ctx context.Context, key string, index int) (string, error)

LIndex to get value from a certain list index

func (*Redigo) LLen

func (rdg *Redigo) LLen(ctx context.Context, key string) (int, error)

LLen get the length of the list

func (*Redigo) LPop

func (rdg *Redigo) LPop(ctx context.Context, key string) (string, error)

LPop removes and get the first element in the list

func (*Redigo) LPush

func (rdg *Redigo) LPush(ctx context.Context, key string, values ...interface{}) (int, error)

LPush prepend values to the list

func (*Redigo) LPushX

func (rdg *Redigo) LPushX(ctx context.Context, key string, values ...interface{}) (int, error)

LPushX prepend values to the list

func (*Redigo) LRem

func (rdg *Redigo) LRem(ctx context.Context, key, value string, count int) (int, error)

LRem command

func (*Redigo) LSet

func (rdg *Redigo) LSet(ctx context.Context, key, value string, index int) (int, error)

LSet to set value to some index

func (*Redigo) LTrim

func (rdg *Redigo) LTrim(ctx context.Context, key string, start, stop int) (string, error)

LTrim command

func (*Redigo) MGet

func (rdg *Redigo) MGet(ctx context.Context, keys ...string) ([]string, error)

MGet keys

func (*Redigo) MSet

func (rdg *Redigo) MSet(ctx context.Context, pairs ...interface{}) (string, error)

MSet keys and values please use basic types only (no struct, array, or map) for arguments

func (*Redigo) Ping

func (rdg *Redigo) Ping(ctx context.Context) (string, error)

Ping the redis

func (*Redigo) Set

func (rdg *Redigo) Set(ctx context.Context, key string, value interface{}) (string, error)

Set key and value

func (*Redigo) SetEX

func (rdg *Redigo) SetEX(ctx context.Context, key string, value interface{}, expire int) (string, error)

SetEX key and value It sets the key wich will expired in `expire` seconds

func (*Redigo) SetNX

func (rdg *Redigo) SetNX(ctx context.Context, key string, value interface{}, expire int) (int, error)

SetNX do SETNX (only set if not exist) with SET's NX & EX args. It sets the key which will expired in `expire` seconds

Jump to

Keyboard shortcuts

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