redis

package
v0.0.0-...-04c1826 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(key string) error

func Do

func Do(commandName string, args ...interface{}) (reply interface{}, err error)

func Get

func Get(key string) interface{}

func HDel

func HDel(key interface{}, fields ...interface{}) (res int, err error)

func HGet

func HGet(key, field string) (res string, err error)

func HGetInt

func HGetInt(key, field string) (res int, err error)

func HMSet

func HMSet(key string, fields ...interface{}) (res string, err error)

func HSet

func HSet(key, field string, value interface{}) (res int, err error)

func Init

func Init(c *config.Conf)

func IsExist

func IsExist(key string) bool

func SAdd

func SAdd(key string, members ...interface{}) (res int, err error)

set 增

func SMembers

func SMembers(key string) (res []string, err error)

all

func SRem

func SRem(key string, members ...interface{}) (res int, err error)

func Set

func Set(key string, val interface{}, timeout time.Duration) (err error)

func ZAdd

func ZAdd(key string, args ...interface{}) (res int, err error)

SortSet 增

func ZIncrby

func ZIncrby(key string, incr int, member string) (res int, err error)

改(+ / -)

func ZRange

func ZRange(key string, args ...interface{}) (res []string, err error)

func ZRem

func ZRem(key string, members ...interface{}) (res int, err error)

func ZScore

func ZScore(key, member string) (res float64, err error)

查 score

Types

type Redis

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

Redis redis cache

func NewRedis

func NewRedis(opts *RedisOpts) *Redis

NewRedis 实例化

func (*Redis) Delete

func (r *Redis) Delete(key string) error

Delete 删除

func (*Redis) Do

func (r *Redis) Do(commandName string, args ...interface{}) (reply interface{}, err error)

func (*Redis) Get

func (r *Redis) Get(key string) interface{}

Get 获取一个值

func (*Redis) IsExist

func (r *Redis) IsExist(key string) bool

IsExist 判断key是否存在

func (*Redis) Set

func (r *Redis) Set(key string, val interface{}, timeout time.Duration) (err error)

Set 设置一个值

func (*Redis) SetConn

func (r *Redis) SetConn(conn *redis.Pool)

SetConn 设置conn

type RedisOpts

type RedisOpts struct {
	Host        string `yml:"host" json:"host"`
	Password    string `yml:"password" json:"password"`
	Database    int    `yml:"database" json:"database"`
	MaxIdle     int    `yml:"max_idle" json:"max_idle"`
	MaxActive   int    `yml:"max_active" json:"max_active"`
	IdleTimeout int32  `yml:"idle_timeout" json:"idle_timeout"` //second
}

RedisOpts redis 连接属性

Jump to

Keyboard shortcuts

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