1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-22 22:30:49 +00:00

improve the Put #896

This commit is contained in:
astaxie 2014-10-31 00:28:51 +08:00
parent 71149218d1
commit db43892fe6

View File

@ -75,14 +75,13 @@ func (rc *RedisCache) Get(key string) interface{} {
// put cache to redis.
func (rc *RedisCache) Put(key string, val interface{}, timeout int64) error {
var err error
if _, err = rc.do("SET", key, val); err != nil {
if _, err = rc.do("SETEX", key, timeout, val); err != nil {
return err
}
if _, err = rc.do("HSET", rc.key, key, true); err != nil {
return err
}
_, err = rc.do("EXPIRE", key, timeout)
return err
}