mirror of
https://gitee.com/johng/gf.git
synced 2024-11-29 18:57:44 +08:00
fix: memory leak when gcache.NewAdapterMemory with lru (#3241)
This commit is contained in:
parent
8af1eb693e
commit
5a01798481
@ -67,6 +67,9 @@ func NewAdapterMemory(lruCap ...int) Adapter {
|
||||
c.cap = lruCap[0]
|
||||
c.lru = newMemCacheLru(c)
|
||||
}
|
||||
// Here may be a "timer leak" if adapter is manually changed from memory adapter.
|
||||
// Do not worry about this, as adapter is less changed, and it does nothing if it's not used.
|
||||
gtimer.AddSingleton(context.Background(), time.Second, c.syncEventAndClearExpired)
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,7 @@ package gcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtimer"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
@ -29,9 +27,6 @@ func New(lruCap ...int) *Cache {
|
||||
c := &Cache{
|
||||
localAdapter: memAdapter,
|
||||
}
|
||||
// Here may be a "timer leak" if adapter is manually changed from memory adapter.
|
||||
// Do not worry about this, as adapter is less changed, and it does nothing if it's not used.
|
||||
gtimer.AddSingleton(context.Background(), time.Second, memAdapter.(*AdapterMemory).syncEventAndClearExpired)
|
||||
return c
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user