mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 19:10:54 +00:00
rename vals
This commit is contained in:
parent
b0b9812de6
commit
98e0626f0c
14
cache/memory.go
vendored
14
cache/memory.go
vendored
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user