File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,12 +12,16 @@ import (
1212 "github.com/hyp3rd/hypercache/pkg/backend"
1313)
1414
15- const cacheCapacity = 10
15+ const (
16+ cacheCapacity = 10
17+ evictionInterval = 10 * time .Second
18+ evictionIntervalSlippage = 65 * time .Second
19+ )
1620
1721// This example demonstrates how to setup eviction of items from the cache.
1822func main () {
1923 log .Println ("running an example of eviction with a background 3 seconds interval" )
20- executeExample (constants . DefaultEvictionInterval )
24+ executeExample (evictionInterval )
2125
2226 log .Println ("running an example with background eviction disabled and proactive eviction enabled" )
2327 executeExample (0 )
@@ -81,8 +85,8 @@ func executeExample(evictionInterval time.Duration) {
8185 }
8286
8387 if evictionInterval > 0 {
84- fmt .Fprintln (os .Stdout , "sleeping to allow the eviction loop to complete" , evictionInterval + 2 * time . Second )
85- time .Sleep (evictionInterval + 2 * time . Second )
88+ fmt .Fprintln (os .Stdout , "sleeping to allow the eviction loop to complete" , evictionInterval + evictionIntervalSlippage )
89+ time .Sleep (evictionInterval + evictionIntervalSlippage )
8690 log .Println ("listing all items in the cache the eviction is triggered" )
8791
8892 list , err := cache .List (context .TODO ())
You can’t perform that action at this time.
0 commit comments