1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-25 19:00: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. // MemoryItem store enery cache item.
type MemoryItem struct { type MemoryItem struct {
val interface{} val interface{}
Lastaccess time.Time cratedTime time.Time
expired int64 lifespan int64
} }
func (mi *MemoryItem) isExpire() bool { func (mi *MemoryItem) isExpire() bool {
// expired==0 means never // 0 means forever
if mi.expired == 0 { if mi.lifespan == 0 {
return false 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. // MemoryCache is Memory cache adapter.
@ -89,8 +89,8 @@ func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error
defer bc.Unlock() defer bc.Unlock()
bc.items[name] = &MemoryItem{ bc.items[name] = &MemoryItem{
val: value, val: value,
Lastaccess: time.Now(), cratedTime: time.Now(),
expired: expired, lifespan: expired,
} }
return nil return nil
} }