mirror of
https://github.com/astaxie/beego.git
synced 2025-06-11 09:00:39 +00:00
fix #1530
This commit is contained in:
4
cache/redis/redis.go
vendored
4
cache/redis/redis.go
vendored
@ -109,9 +109,9 @@ ERROR:
|
||||
}
|
||||
|
||||
// Put put cache to redis.
|
||||
func (rc *Cache) Put(key string, val interface{}, timeout int64) error {
|
||||
func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error {
|
||||
var err error
|
||||
if _, err = rc.do("SETEX", key, timeout, val); err != nil {
|
||||
if _, err = rc.do("SETEX", key, int64(timeout.Seconds()), val); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
9
cache/redis/redis_test.go
vendored
9
cache/redis/redis_test.go
vendored
@ -28,7 +28,8 @@ func TestRedisCache(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error("init err")
|
||||
}
|
||||
if err = bm.Put("astaxie", 1, 10); err != nil {
|
||||
timeoutDuration := time.Second * 10
|
||||
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
|
||||
t.Error("set Error", err)
|
||||
}
|
||||
if !bm.IsExist("astaxie") {
|
||||
@ -40,7 +41,7 @@ func TestRedisCache(t *testing.T) {
|
||||
if bm.IsExist("astaxie") {
|
||||
t.Error("check err")
|
||||
}
|
||||
if err = bm.Put("astaxie", 1, 10); err != nil {
|
||||
if err = bm.Put("astaxie", 1, timeoutDuration); err != nil {
|
||||
t.Error("set Error", err)
|
||||
}
|
||||
|
||||
@ -69,7 +70,7 @@ func TestRedisCache(t *testing.T) {
|
||||
}
|
||||
|
||||
//test string
|
||||
if err = bm.Put("astaxie", "author", 10); err != nil {
|
||||
if err = bm.Put("astaxie", "author", timeoutDuration); err != nil {
|
||||
t.Error("set Error", err)
|
||||
}
|
||||
if !bm.IsExist("astaxie") {
|
||||
@ -81,7 +82,7 @@ func TestRedisCache(t *testing.T) {
|
||||
}
|
||||
|
||||
//test GetMulti
|
||||
if err = bm.Put("astaxie1", "author1", 10); err != nil {
|
||||
if err = bm.Put("astaxie1", "author1", timeoutDuration); err != nil {
|
||||
t.Error("set Error", err)
|
||||
}
|
||||
if !bm.IsExist("astaxie1") {
|
||||
|
Reference in New Issue
Block a user