redis操作
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
641 B

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
}