blob: 2fc99ab0f45b5b5e8f70c5938d5b6c35bfe756a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
package simple
import "sync"
// entryPool is a global pool for Entry
// objects, regardless of cache type.
var entryPool sync.Pool
// getEntry fetches an Entry from pool, or allocates new.
func getEntry() *Entry {
v := entryPool.Get()
if v == nil {
return new(Entry)
}
return v.(*Entry)
}
// putEntry replaces an Entry in the pool.
func putEntry(e *Entry) {
e.Key = nil
e.Value = nil
entryPool.Put(e)
}
|