diff --git a/cache2go/cache_store.go b/cache2go/cache_store.go index 4d9cf94e2..68bfee99a 100644 --- a/cache2go/cache_store.go +++ b/cache2go/cache_store.go @@ -2,7 +2,6 @@ package cache2go import ( - "fmt" "strings" "sync" @@ -95,7 +94,7 @@ func (cs cacheDoubleStore) GetKeysForPrefix(prefix string) (keys []string) { // easy to be counted exported by prefix type lrustore struct { store map[string]*lru.Cache - sync.RWMutex + sync.Mutex } func newLruStore() *lrustore { @@ -184,8 +183,8 @@ func (cs lrustore) Put(key string, value interface{}) { } func (cs lrustore) Get(key string) (interface{}, bool) { - cs.RLock() - defer cs.RUnlock() + cs.Lock() + defer cs.Unlock() prefix, key := key[:PREFIX_LEN], key[PREFIX_LEN:] if keyMap, ok := cs.store[prefix]; ok { if ti, exists := keyMap.Get(key); exists { @@ -211,8 +210,8 @@ func (cs lrustore) DeletePrefix(prefix string) { } func (cs lrustore) CountEntriesForPrefix(prefix string) int { - cs.RLock() - defer cs.RUnlock() + cs.Lock() + defer cs.Unlock() if m, ok := cs.store[prefix]; ok { return m.Len() } diff --git a/cache2go/cache_test.go b/cache2go/cache_test.go index 3f0ac59cf..b95386d8b 100644 --- a/cache2go/cache_test.go +++ b/cache2go/cache_test.go @@ -1,6 +1,8 @@ package cache2go -import "testing" +import ( + "testing" +) func TestRemKey(t *testing.T) { Set("t11_mm", "test") diff --git a/test.sh b/test.sh index a54a4907e..8c6ab0558 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ #! /usr/bin/env sh ./build.sh go test $(glide novendor) -exit $? \ No newline at end of file +exit $?