mirror of https://github.com/grafana/grafana.git
uses set instead of add for memcache
set always sets the value regardless.
This commit is contained in:
parent
8db2864fee
commit
33935b09f0
|
|
@ -4,9 +4,5 @@ import "testing"
|
|||
|
||||
func TestIntegrationDatabaseCacheStorage(t *testing.T) {
|
||||
|
||||
client := createTestClient(t, "database")
|
||||
|
||||
CanPutGetAndDeleteCachedObjects(t, client)
|
||||
CanNotFetchExpiredItems(t, client)
|
||||
CanSetInfiniteCacheExpiration(t, client)
|
||||
RunTestsForClient(t, createTestClient(t, "database"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@ func createTestClient(t *testing.T, name string) cacheStorage {
|
|||
return createClient(CacheOpts{name: name}, sqlstore)
|
||||
}
|
||||
|
||||
func TestAllCacheClients(t *testing.T) {
|
||||
clients := []string{"memory"} // add redis, memcache, memory
|
||||
func TestMemoryStorageClient(t *testing.T) {
|
||||
|
||||
for _, v := range clients {
|
||||
client := createTestClient(t, v)
|
||||
client := createTestClient(t, "memory")
|
||||
RunTestsForClient(t, client)
|
||||
}
|
||||
|
||||
CanPutGetAndDeleteCachedObjects(t, client)
|
||||
CanNotFetchExpiredItems(t, client)
|
||||
CanSetInfiniteCacheExpiration(t, client)
|
||||
}
|
||||
func RunTestsForClient(t *testing.T, client cacheStorage) {
|
||||
CanPutGetAndDeleteCachedObjects(t, client)
|
||||
CanNotFetchExpiredItems(t, client)
|
||||
CanSetInfiniteCacheExpiration(t, client)
|
||||
}
|
||||
|
||||
func CanPutGetAndDeleteCachedObjects(t *testing.T, client cacheStorage) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func (s *memcacheStorage) Put(key string, val interface{}, expires time.Duration
|
|||
|
||||
memcacheItem := newItem(key, bytes, int32(expires))
|
||||
|
||||
return s.c.Add(memcacheItem)
|
||||
return s.c.Set(memcacheItem)
|
||||
}
|
||||
|
||||
// Get gets value by given key in the cache.
|
||||
|
|
|
|||
|
|
@ -3,10 +3,5 @@ package distcache
|
|||
import "testing"
|
||||
|
||||
func TestMemcachedCacheStorage(t *testing.T) {
|
||||
|
||||
client := createTestClient(t, "memcache")
|
||||
|
||||
CanPutGetAndDeleteCachedObjects(t, client)
|
||||
CanNotFetchExpiredItems(t, client)
|
||||
CanSetInfiniteCacheExpiration(t, client)
|
||||
RunTestsForClient(t, createTestClient(t, "memcache"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,5 @@ package distcache
|
|||
import "testing"
|
||||
|
||||
func TestRedisCacheStorage(t *testing.T) {
|
||||
|
||||
client := createTestClient(t, "redis")
|
||||
|
||||
CanPutGetAndDeleteCachedObjects(t, client)
|
||||
CanNotFetchExpiredItems(t, client)
|
||||
CanSetInfiniteCacheExpiration(t, client)
|
||||
RunTestsForClient(t, createTestClient(t, "redis"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue