mirror of
https://github.com/astaxie/beego.git
synced 2024-11-04 21:30:55 +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:
parent
a411042416
commit
0b39091292
4
cache/memory.go
vendored
4
cache/memory.go
vendored
@ -79,6 +79,10 @@ func (bc *MemoryCache) GetMulti(names []string) []interface{} {
|
|||||||
func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error {
|
func (bc *MemoryCache) Put(name string, value interface{}, expired int64) error {
|
||||||
bc.lock.Lock()
|
bc.lock.Lock()
|
||||||
defer bc.lock.Unlock()
|
defer bc.lock.Unlock()
|
||||||
|
if expired == 0 {
|
||||||
|
//ten years,behave as the file cache
|
||||||
|
expired = 86400 * 365 * 10
|
||||||
|
}
|
||||||
bc.items[name] = &MemoryItem{
|
bc.items[name] = &MemoryItem{
|
||||||
val: value,
|
val: value,
|
||||||
Lastaccess: time.Now(),
|
Lastaccess: time.Now(),
|
||||||
|
Loading…
Reference in New Issue
Block a user