mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 10:40:19 +00:00
fix #1530
This commit is contained in:
5
cache/memcache/memcache.go
vendored
5
cache/memcache/memcache.go
vendored
@ -37,6 +37,7 @@ import (
|
||||
"github.com/bradfitz/gomemcache/memcache"
|
||||
|
||||
"github.com/astaxie/beego/cache"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Cache Memcache adapter.
|
||||
@ -89,7 +90,7 @@ func (rc *Cache) GetMulti(keys []string) []interface{} {
|
||||
}
|
||||
|
||||
// Put put value to memcache. only support string.
|
||||
func (rc *Cache) Put(key string, val interface{}, timeout int64) error {
|
||||
func (rc *Cache) Put(key string, val interface{}, timeout time.Duration) error {
|
||||
if rc.conn == nil {
|
||||
if err := rc.connectInit(); err != nil {
|
||||
return err
|
||||
@ -99,7 +100,7 @@ func (rc *Cache) Put(key string, val interface{}, timeout int64) error {
|
||||
if !ok {
|
||||
return errors.New("val must string")
|
||||
}
|
||||
item := memcache.Item{Key: key, Value: []byte(v), Expiration: int32(timeout)}
|
||||
item := memcache.Item{Key: key, Value: []byte(v), Expiration: int32(timeout.Seconds())}
|
||||
return rc.conn.Set(&item)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user