redis

package
v0.0.0-...-af31a00 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(cmdName string, args ...interface{}) (interface{}, error)

func DoLua

func DoLua(luaStr string, keyCount int, keyAndArgs ...interface{}) (interface{}, error)

注意:使用script传入的key 和 args 都是string

func DoLuaInt

func DoLuaInt(luaStr string, keyCount int, keyAndArgs ...interface{}) (int, error)

func DoLuaInt64

func DoLuaInt64(luaStr string, keyCount int, keyAndArgs ...interface{}) (int64, error)

func DoLuaUint

func DoLuaUint(luaStr string, keyCount int, keyAndArgs ...interface{}) (uint32, error)

func GetBool

func GetBool(cmdName string, args ...interface{}) (bool, error)

封装redigo的get方法

func GetBytes

func GetBytes(cmdName string, args ...interface{}) ([]byte, error)

func GetInt

func GetInt(cmdName string, args ...interface{}) (int, error)

func GetInt64

func GetInt64(cmdName string, args ...interface{}) (int64, error)

func GetRedisConn

func GetRedisConn() goredis.Conn

func GetString

func GetString(cmdName string, args ...interface{}) (string, error)

func GetStringMap

func GetStringMap(cmdName string, args ...interface{}) (map[string]string, error)

func GetStrings

func GetStrings(cmdName string, args ...interface{}) ([]string, error)

func GetValues

func GetValues(cmdName string, args ...interface{}) ([]interface{}, error)

func HGetall

func HGetall(key string, args interface{}) error

func MSet

func MSet(cmdName string, key string, arg interface{}) (interface{}, error)

/////////////////////////////////////////////////////// Hash 结构体操作 /////////////////////////////////////////////////////// 支持多k-v操作,需要指定key 例如:MSET,HMSET等 arg字段支持slice、map和struct

func NewRedisCache

func NewRedisCache()

初始化redis连接池

func ReplyGet

func ReplyGet(cmdName string, reply interface{}, args ...interface{}) error

指定返回值的get操作 reply 为返回值,需要传入指针(必须是指针) 该方法主要封装了redigo内置的类型转换方法

func ScanSlice

func ScanSlice(cmdName string, args ...interface{}) error

func ScanStruct

func ScanStruct(cmdName string, args ...interface{}) error

func StructHMset

func StructHMset(key string, arg interface{}) (interface{}, error)

hash表的结构体set

Types

type RedisCache

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

redis cache

func Connect

func Connect() *RedisCache

func (*RedisCache) Do

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

/////////////////////////////////////////////////////// actually do the redis cmds

func (*RedisCache) GetMulti

func (rc *RedisCache) GetMulti(keys []string) []interface{}

GetMulti get cache from redis.

func (*RedisCache) StartAndGC

func (rc *RedisCache) StartAndGC(config string) error

config is like {"key":"collection key","conn":"connection info","dbNum":"0"} the cache item in redis are stored forever, so no gc operation.

Jump to

Keyboard shortcuts

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