|
|
- package redis
-
- import (
- redisdb "github.com/gomodule/redigo/redis"
- )
-
- /**
- * key增加
- */
- func Incrby(key string, value interface{}) (int64, error) {
- c := GetConn()
- var err error
- var reply interface{}
- reply, err = c.Do("INCRBY", key, value)
-
- CloseConn(c)
-
- if err != nil {
- return 0, err
- }
- ret, err := redisdb.Int64(reply, err)
- return ret, err
- }
-
- /**
- * key减
- */
- func Decrby(key string, value interface{}) (int64, error) {
- c := GetConn()
- var err error
- var reply interface{}
- reply, err = c.Do("DECRBY", key, value)
-
- CloseConn(c)
-
- if err != nil {
- return 0, err
- }
- ret, err := redisdb.Int64(reply, err)
- return ret, err
- }
|