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.

39 lines
585 B

package redis
import (
redisdb "github.com/gomodule/redigo/redis"
)
/**
* 设置有效期
*/
func SetExpire(key string, expire int64) (int64, error) {
c := GetConn()
var err error
var reply interface{}
reply, err = c.Do("expire", key, expire)
CloseConn(c)
if err != nil {
return 0, err
}
return redisdb.Int64(reply, err)
}
/**
* 获取有效期
*/
func GetExpire(key string) (int64, error) {
c := GetConn()
var err error
var reply interface{}
reply, err = c.Do("TTL", key)
CloseConn(c)
if err != nil {
return 0, err
}
return redisdb.Int64(reply, err)
}