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

rename vals

This commit is contained in:
JessonChan 2016-01-07 09:25:06 +08:00
parent b0b9812de6
commit 98e0626f0c

14
cache/memory.go vendored
View File

@ -30,16 +30,16 @@ var (
// MemoryItem store enery cache item.
type MemoryItem struct {
val interface{}
Lastaccess time.Time
expired int64
cratedTime time.Time
lifespan int64
}
func (mi *MemoryItem) isExpire() bool {
// expired==0 means never
if mi.expired == 0 {
// 0 means forever
if mi.lifespan == 0 {
return false
}
return time.Now().Unix()-mi.Lastaccess.Unix() > mi.expired
return time.Now().Unix()-mi.cratedTime.Unix() > mi.lifespan
}
// MemoryCache is Memory cache adapter.
@ -89,8 +89,8 @@ func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error
defer bc.Unlock()
bc.items[name] = &MemoryItem{
val: value,
Lastaccess: time.Now(),
expired: expired,
cratedTime: time.Now(),
lifespan: expired,
}
return nil
}