Merge pull request #106 from rmweir/disable-cache

Change cache default to false
This commit is contained in:
Ricardo Weir 2023-05-11 16:25:09 -07:00 committed by GitHub
commit 32799193cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View File

@ -29,7 +29,7 @@ const (
// Not related to the total size in memory of the cache, as any item could take any amount of memory. // Not related to the total size in memory of the cache, as any item could take any amount of memory.
cacheSizeEnv = "CATTLE_REQUEST_CACHE_SIZE_INT" cacheSizeEnv = "CATTLE_REQUEST_CACHE_SIZE_INT"
defaultCacheSize = 1000 defaultCacheSize = 1000
// Set to non-empty to disable list request caching entirely. // Set to "false" to enable list request caching.
cacheDisableEnv = "CATTLE_REQUEST_CACHE_DISABLED" cacheDisableEnv = "CATTLE_REQUEST_CACHE_DISABLED"
) )
@ -60,7 +60,7 @@ func NewStore(partitioner Partitioner, asl accesscontrol.AccessSetLookup) *Store
Partitioner: partitioner, Partitioner: partitioner,
asl: asl, asl: asl,
} }
if v := os.Getenv(cacheDisableEnv); v == "" { if v := os.Getenv(cacheDisableEnv); v == "false" {
s.listCache = cache.NewLRUExpireCache(cacheSize) s.listCache = cache.NewLRUExpireCache(cacheSize)
} }
return s return s

View File

@ -1941,8 +1941,8 @@ func TestList(t *testing.T) {
} }
} }
asl := &mockAccessSetLookup{userRoles: test.access} asl := &mockAccessSetLookup{userRoles: test.access}
if test.disableCache { if !test.disableCache {
t.Setenv("CATTLE_REQUEST_CACHE_DISABLED", "Y") t.Setenv("CATTLE_REQUEST_CACHE_DISABLED", "false")
} }
store := NewStore(mockPartitioner{ store := NewStore(mockPartitioner{
stores: stores, stores: stores,
@ -2024,7 +2024,6 @@ func TestListByRevision(t *testing.T) {
}, },
}, asl) }, asl)
req := newRequest("", "user1") req := newRequest("", "user1")
t.Setenv("CATTLE_REQUEST_CACHE_DISABLED", "Y")
got, gotErr := store.List(req, schema) got, gotErr := store.List(req, schema)
assert.Nil(t, gotErr) assert.Nil(t, gotErr)