redis

package
v0.0.0-...-6d34543 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(reply interface{}, err error) (bool, error)

refer redis.Bool.

func ByteSlices

func ByteSlices(reply interface{}, err error) ([][]byte, error)

refer redis.ByteSlices.

func Bytes

func Bytes(reply interface{}, err error) ([]byte, error)

refer redis.Bytes.

func Float64

func Float64(reply interface{}, err error) (float64, error)

refer redis.Float64.

func Float64s

func Float64s(reply interface{}, err error) ([]float64, error)

refer redis.Float64s.

func Int

func Int(reply interface{}, err error) (int, error)

refer redis.Int.

func Int64

func Int64(reply interface{}, err error) (int64, error)

refer redis.Int64.

func Int64Map

func Int64Map(result interface{}, err error) (map[string]int64, error)

refer redis.IntMap.

func Int64s

func Int64s(reply interface{}, err error) ([]int64, error)

refer redis.Int64s.

func IntMap

func IntMap(result interface{}, err error) (map[string]int, error)

refer redis.IntMap.

func Ints

func Ints(reply interface{}, err error) ([]int, error)

refer redis.Ints.

func Positions

func Positions(result interface{}, err error) ([]*[2]float64, error)

refer redis.Positions.

func String

func String(reply interface{}, err error) (string, error)

refer redis.String.

func StringMap

func StringMap(result interface{}, err error) (map[string]string, error)

refer redis.StringMap.

func Strings

func Strings(reply interface{}, err error) ([]string, error)

refer redis.Strings.

func Struct

func Struct(result interface{}, err error, v ...interface{}) error

func Uint64

func Uint64(reply interface{}, err error) (uint64, error)

refer redis.Uint64.

func Values

func Values(reply interface{}, err error) ([]interface{}, error)

refer redis.Values.

Types

type Client

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

func NewClient

func NewClient(options ...Option) *Client

func (*Client) BLPop

func (c *Client) BLPop(ctx context.Context, key string, timeout int) (interface{}, error)

------------------------------------------------------------ // --------------------------- LIST ------------------------- // ----------------------------------------------------------- // timeout 单位s, 0表示无限期阻塞

func (*Client) BRPop

func (c *Client) BRPop(ctx context.Context, key string, timeout int) (interface{}, error)

func (*Client) Close

func (c *Client) Close() error

func (*Client) DeleteKey

func (c *Client) DeleteKey(ctx context.Context, key string) (bool, error)

func (*Client) Do

func (c *Client) Do(ctx context.Context, command string, args ...interface{}) (reply interface{}, err error)

func (*Client) DoWithMetric

func (c *Client) DoWithMetric(redisConn redis.Conn, cmd string, args ...interface{}) (interface{}, error)

func (*Client) Exists

func (c *Client) Exists(ctx context.Context, key string) (bool, error)

func (*Client) Expire

func (c *Client) Expire(ctx context.Context, key string, expiration int64) error

key 设置过期时间 单位s

func (*Client) Get

func (c *Client) Get(ctx context.Context, key string) (string, error)

------------------------------------------------------------ // --------------------------- STRING ------------------------- // ----------------------------------------------------------- // GET

func (*Client) GetBytes

func (c *Client) GetBytes(ctx context.Context, key string) ([]byte, error)

func (*Client) GetInt

func (c *Client) GetInt(ctx context.Context, key string) (int, error)

func (*Client) GetRedisConn

func (c *Client) GetRedisConn() redis.Conn

func (*Client) HGet

func (c *Client) HGet(ctx context.Context, key, field string) ([]byte, error)

func (*Client) HGetAll

func (c *Client) HGetAll(ctx context.Context, key string, val interface{}) error

func (*Client) HMGet

func (c *Client) HMGet(ctx context.Context, key string, field ...interface{}) ([]string, error)

func (*Client) HMSet

func (c *Client) HMSet(ctx context.Context, key string, val interface{}) error

func (*Client) HSet

func (c *Client) HSet(ctx context.Context, key string, field string, val interface{}) error

------------------------------------------------------------ // --------------------------- HASH ------------------------- // ----------------------------------------------------------- //

func (*Client) IncrBy

func (c *Client) IncrBy(ctx context.Context, key string, step int) (int, error)

INCRBY

func (*Client) LPop

func (c *Client) LPop(ctx context.Context, key string) (interface{}, error)

func (*Client) LPush

func (c *Client) LPush(ctx context.Context, key string, val interface{}) error

LPush 将一个值插入到列表头部

func (*Client) LRange

func (c *Client) LRange(ctx context.Context, key string, start, end int) (interface{}, error)

区间以偏移量 start 和 end 0 表示列表的第一个元素, 1 表示列表的第二个元素,以此类推。 -1 表示列表的最后一个元素, -2 表示列表的倒数第二个元素,以此类推。 end (闭区间)

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) RPop

func (c *Client) RPop(ctx context.Context, key string) (interface{}, error)

func (*Client) RPush

func (c *Client) RPush(ctx context.Context, key string, val interface{}) error

RPush 将一个值插入到列表尾部

func (*Client) SAdd

func (c *Client) SAdd(ctx context.Context, key string, fields []interface{}) (bool, error)

------------------------------------------------------------ // --------------------------- SET --------------------------- // ----------------------------------------------------------- //

func (*Client) SMembers

func (c *Client) SMembers(ctx context.Context, key string) (interface{}, error)

func (*Client) SRem

func (c *Client) SRem(ctx context.Context, key string, members []interface{}) (interface{}, error)

func (*Client) SelectDB

func (c *Client) SelectDB(ctx context.Context, db int) error

func (*Client) Set

func (c *Client) Set(ctx context.Context, key string, val interface{}, expiration int64) error

SET, expiration 单位s, 0永久

func (*Client) SisMember

func (c *Client) SisMember(ctx context.Context, key string, member interface{}) (interface{}, error)

func (*Client) Stats

func (c *Client) Stats()

func (*Client) SubChannels

func (c *Client) SubChannels(ctx context.Context,
	onStart func() error,
	onMessage func(channel string, data []byte) error,
	channels ...string) error

func (*Client) TraceWithSpanContext

func (c *Client) TraceWithSpanContext(spCtx opentracing.SpanContext) *TraceClient

func (*Client) ZAdd

func (c *Client) ZAdd(ctx context.Context, key string, score int64, member string) (interface{}, error)

------------------------------------------------------------ // ------------------------ SORTED SET ----------------------- // ----------------------------------------------------------- //

func (*Client) ZRange

func (c *Client) ZRange(ctx context.Context, key string, from, to int64) (map[string]int64, error)

ZRange 返回有序集中,指定区间内的成员。其中成员的位置按分数值递增(从小到大)来排序。具有相同分数值的成员按字典序来排列。 以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,以此类推。或 以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Client) ZRank

func (c *Client) ZRank(ctx context.Context, key, member string) (int64, error)

返回有序集中指定成员的排名。其中有序集成员按分数值递增(从小到大)顺序排列。score 值最小的成员排名为 0

func (*Client) ZRem

func (c *Client) ZRem(ctx context.Context, key string, member string) (interface{}, error)

func (*Client) ZRevrank

func (c *Client) ZRevrank(ctx context.Context, key, member string) (int64, error)

返回有序集中成员的排名。其中有序集成员按分数值递减(从大到小)排序。分数值最大的成员排名为 0 。

func (*Client) ZScore

func (c *Client) ZScore(ctx context.Context, key string, member string) (int64, error)

返回有序集成员member的score值。如果member元素不是有序集key的成员,或key不存在,返回nil 。

type Option

type Option func(c *Client)

func WithStateTicker

func WithStateTicker(stateTicker time.Duration) Option

type TraceClient

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

Jump to

Keyboard shortcuts

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