Commit 0b390912 authored by JessonChan's avatar JessonChan

mem cache put function fixed

when a expire duration==0,it means forever
https://github.com/astaxie/beego/issues/1260
parent a4110424
...@@ -79,6 +79,10 @@ func (bc *MemoryCache) GetMulti(names []string) []interface{} { ...@@ -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(),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment