improve the Put #896
Showing
1 changed file
with
1 additions
and
2 deletions
| ... | @@ -75,14 +75,13 @@ func (rc *RedisCache) Get(key string) interface{} { | ... | @@ -75,14 +75,13 @@ func (rc *RedisCache) Get(key string) interface{} { |
| 75 | // put cache to redis. | 75 | // put cache to redis. |
| 76 | func (rc *RedisCache) Put(key string, val interface{}, timeout int64) error { | 76 | func (rc *RedisCache) Put(key string, val interface{}, timeout int64) error { |
| 77 | var err error | 77 | var err error |
| 78 | if _, err = rc.do("SET", key, val); err != nil { | 78 | if _, err = rc.do("SETEX", key, timeout, val); err != nil { |
| 79 | return err | 79 | return err |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | if _, err = rc.do("HSET", rc.key, key, true); err != nil { | 82 | if _, err = rc.do("HSET", rc.key, key, true); err != nil { |
| 83 | return err | 83 | return err |
| 84 | } | 84 | } |
| 85 | _, err = rc.do("EXPIRE", key, timeout) | ||
| 86 | return err | 85 | return err |
| 87 | } | 86 | } |
| 88 | 87 | ... | ... |
-
Please register or sign in to post a comment