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

mem cache put function fixed

when a expire duration==0,it means forever
https://github.com/astaxie/beego/issues/1260
This commit is contained in:
JessonChan 2016-01-06 15:05:29 +08:00
parent a411042416
commit 0b39091292

4
cache/memory.go vendored
View File

@ -79,6 +79,10 @@ func (bc *MemoryCache) GetMulti(names []string) []interface{} {
func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error {
bc.lock.Lock()
defer bc.lock.Unlock()
if expired == 0 {
//ten years,behave as the file cache
expired = 86400 * 365 * 10
}
bc.items[name] = &MemoryItem{
val: value,
Lastaccess: time.Now(),