redis

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: MIT Imports: 4 Imported by: 0

README

使用

go get github.com/wuyan94zl/gowebpkg/redis

    // 初始化连接池
    config := redis.Config{Host: "127.0.0.1:6379", Password: "123456", MaxActive: 200, MaxIdle: 50, IdleTimeout: 300}
    redis.ConRedis(config)

    // 使用
    redis.Set("key","val")

Documentation

Index

Constants

This section is empty.

Variables

Functions

func ConRedis

func ConRedis(conf Config)

func Decr

func Decr(key string) (int64, error)

func Del

func Del(key string) (bool, error)

func Expire

func Expire(key string, ttl int64) (bool, error)

func Get

func Get(key string) (string, error)

func HDel

func HDel(hashKey string, key string) (bool, error)

func HExists

func HExists(hashKey string, key string) (bool, error)

func HGet

func HGet(hashKey string, key string) (string, error)

func HGetAll

func HGetAll(hashKey string) (map[string]string, error)

func HIncrBy

func HIncrBy(hashKey string, key string, num int64) (int64, error)

func HKeys

func HKeys(hashKey string) ([]string, error)

func HLen

func HLen(hashKey string) (int64, error)

func HMGet

func HMGet(hashKey string, keys ...interface{}) (map[string]string, error)

func HMSet

func HMSet(hashKey string, keyVal ...KeyVal) (string, error)

func HSet

func HSet(hashKey string, key string, val interface{}) (bool, error)

func HVals

func HVals(hashKey string) ([]string, error)

func HashFuncTest

func HashFuncTest()

func Incr

func Incr(key string) (int64, error)

func IncrBy

func IncrBy(key string, num int64) (int64, error)

func KeyFuncTest

func KeyFuncTest()

func LIndex

func LIndex(listKey string, i int64) (string, error)

func LInsert

func LInsert(listKey string, target string, val string) (int64, error)

func LLen

func LLen(listKey string) (int64, error)

func LPop

func LPop(listKey string) (string, error)

queue consumption

func LPush

func LPush(listKey string, val string) (int64, error)

queue right

func LRange

func LRange(listKey string, start int64, end int64) ([]string, error)

func LSet

func LSet(listKey string, index int64, val string) (string, error)

func ListFuncTest

func ListFuncTest()

func Lock

func Lock(key string, ttl ...int64) bool

func MGet

func MGet(keys ...interface{}) (map[string]string, error)

func MSet

func MSet(keyVal ...KeyVal) (bool, error)

func RPop

func RPop(listKey string) (string, error)

queue consumption

func RPopPush

func RPopPush(listKey string, toListKey string) (string, error)

func RPush

func RPush(listKey string, val string) (int64, error)

queue right

func SAdd

func SAdd(setKey string, members ...string) (int64, error)

添加一个或多个成员

func SCard

func SCard(setKey string) (int64, error)

获取集合成员数

func SDiff

func SDiff(setKeys ...interface{}) ([]string, error)

返回其他集合不存在的成员列表

func SInter

func SInter(setKeys ...interface{}) ([]string, error)

返回多个集合交集

func SIsMember

func SIsMember(setKey string, member string) (bool, error)

判断集合是否存在成员

func SMembers

func SMembers(setKey string) ([]string, error)

获取集合成员列表

func SMove

func SMove(source string, destination string, member string) (bool, error)

把成员member从source集合移动到destination集合

func SPop

func SPop(setKey string) (string, error)

随机获取并移除一个成员

func SRandMember

func SRandMember(setKey string, count int64) ([]string, error)

随机获取 count 个成员

func SRem

func SRem(setKey string, members ...string) (int64, error)

移除一个或多个成员

func SUnion

func SUnion(setKeys ...interface{}) ([]string, error)

返回多个集合并集

func Set

func Set(key string, val interface{}) (bool, error)

string action

func SetEx

func SetEx(key string, val string, ttl int64) (string, error)

func SetFuncTest

func SetFuncTest()

func SetNx

func SetNx(key string, val string, ttl ...int64) (bool, error)

func UnLock

func UnLock(key string) (bool, error)

func ZAdd

func ZAdd(setKey string, members ...SortSet) (int64, error)

添加一个或多个有序集合

func ZCard

func ZCard(setKey string) (int64, error)

集合成员数

func ZCount

func ZCount(setKey string, min int64, max int64) (int64, error)

计算score 之间的数量

func ZIncrBy

func ZIncrBy(setKey string, member string, sort int64) (string, error)

对成员分数修改

func ZRangeByScoreMap

func ZRangeByScoreMap(setKey string, start string, stop string) (map[string]string, error)

取值 score 区间 -inf => (开始) +inf => (结束) (666 => (大于666) 666 => (大于等于666) 返回 map

func ZRangeMap

func ZRangeMap(setKey string, start int64, stop int64) (map[string]string, error)

取范围 0 - -1 返回 map

func ZRank

func ZRank(setKey string, member string) (int64, error)

获取member 排名 递增

func ZRem

func ZRem(setKey string, members ...interface{}) (int64, error)

移除有序集合一个或多个成员

func ZRemByRank

func ZRemByRank(setKey string, min int64, max int64) (int64, error)

移除有序集合 指定排名区间的成员

func ZRemByScore

func ZRemByScore(setKey string, min int64, max int64) (int64, error)

移除有序集合 指定分数区间的成员

func ZRevRank

func ZRevRank(setKey string, member string) (int64, error)

获取member 排名 递减

func ZScore

func ZScore(setKey string, member string) (string, error)

返回有序集合成员的分数

Types

type Config

type Config struct {
	Host        string
	Password    string
	MaxIdle     int
	IdleTimeout time.Duration
	MaxActive   int
}

type KeyVal

type KeyVal struct {
	Key string
	Val interface{}
}

type SortSet

type SortSet struct {
	Score  int64
	Member string
}

func ZRange

func ZRange(setKey string, start int64, stop int64) ([]SortSet, error)

取范围 0 - -1 返回 排序 递增

func ZRangeByScore

func ZRangeByScore(setKey string, start string, stop string) ([]SortSet, error)

取值 score 区间 -inf => (开始) +inf => (结束) (666 => (大于666) 666 => (大于等于666) 递增

func ZRevRange

func ZRevRange(setKey string, start int64, stop int64) ([]SortSet, error)

取范围 0 - -1 返回 排序 递减

func ZRevRangeByScore

func ZRevRangeByScore(setKey string, start string, stop string) ([]SortSet, error)

取值 score 区间 -inf => (开始) +inf => (结束) (666 => (大于666) 666 => (大于等于666) 递减

Jump to

Keyboard shortcuts

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