|
@@ -4,7 +4,6 @@ import (
|
|
|
"container/list"
|
|
|
"sync"
|
|
|
"sync/atomic"
|
|
|
- //"fmt"
|
|
|
)
|
|
|
|
|
|
// An AtomicInt is an int64 to be accessed atomically.
|
|
@@ -12,11 +11,11 @@ type AtomicInt int64
|
|
|
|
|
|
// MemCache is an LRU cache. It is safe for concurrent access.
|
|
|
type MemCache struct {
|
|
|
+ hits, gets AtomicInt
|
|
|
mutex sync.RWMutex
|
|
|
maxItemSize int
|
|
|
cacheList *list.List
|
|
|
cache map[interface{}]*list.Element
|
|
|
- hits, gets AtomicInt
|
|
|
}
|
|
|
|
|
|
type entry struct {
|
|
@@ -31,6 +30,8 @@ func NewMemCache(maxItemSize int) *MemCache {
|
|
|
maxItemSize: maxItemSize,
|
|
|
cacheList: list.New(),
|
|
|
cache: make(map[interface{}]*list.Element),
|
|
|
+ hits: 0,
|
|
|
+ gets: 0,
|
|
|
}
|
|
|
}
|
|
|
|