fs/cache: add --fs-cache-expire-duration to control the fs cache
This commit makes the previously statically configured fs cache configurable. It introduces two parameters `--fs-cache-expire-duration` and `--fs-cache-expire-interval` to control the caching of the items. It also adds new interfaces to lib/cache to set these.
This commit is contained in:
parent
60bc7a079a
commit
c0c74003f2
7 changed files with 119 additions and 19 deletions
27
lib/cache/cache_test.go
vendored
27
lib/cache/cache_test.go
vendored
|
@ -100,7 +100,7 @@ func TestPut(t *testing.T) {
|
|||
func TestCacheExpire(t *testing.T) {
|
||||
c, create := setup(t)
|
||||
|
||||
c.expireInterval = time.Millisecond
|
||||
c.SetExpireInterval(time.Millisecond)
|
||||
assert.Equal(t, false, c.expireRunning)
|
||||
|
||||
_, err := c.Get("/", create)
|
||||
|
@ -127,6 +127,31 @@ func TestCacheExpire(t *testing.T) {
|
|||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
func TestCacheNoExpire(t *testing.T) {
|
||||
c, create := setup(t)
|
||||
|
||||
assert.False(t, c.noCache())
|
||||
|
||||
c.SetExpireDuration(0)
|
||||
assert.Equal(t, false, c.expireRunning)
|
||||
|
||||
assert.True(t, c.noCache())
|
||||
|
||||
f, err := c.Get("/", create)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, f)
|
||||
|
||||
c.mu.Lock()
|
||||
assert.Equal(t, 0, len(c.cache))
|
||||
c.mu.Unlock()
|
||||
|
||||
c.Put("/alien", "slime")
|
||||
|
||||
c.mu.Lock()
|
||||
assert.Equal(t, 0, len(c.cache))
|
||||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
func TestCachePin(t *testing.T) {
|
||||
c, create := setup(t)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue