db43892f by astaxie

improve the Put #896

1 parent 71149218
...@@ -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
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!