Browse Source

Added explicit test cases for LRU behavior.

master
jdl 1 year ago
parent
commit
06ebdecdf9
1 changed files with 42 additions and 0 deletions
  1. +42
    -0
      kvmemcache/cache_test.go

+ 42
- 0
kvmemcache/cache_test.go View File

@ -151,6 +151,48 @@ func TestCache_basic(t *testing.T) {
Keys: []string{"d", "e", "err"},
Stats: Stats{Hits: 3, Misses: 7},
},
}, {
name: "reload-all a",
key: "a",
state: State{
Keys: []string{"a", "d", "e", "err"},
Stats: Stats{Hits: 3, Misses: 8},
},
}, {
name: "reload-all b",
key: "b",
state: State{
Keys: []string{"a", "b", "e", "err"},
Stats: Stats{Hits: 3, Misses: 9},
},
}, {
name: "reload-all c",
key: "c",
state: State{
Keys: []string{"a", "b", "c", "err"},
Stats: Stats{Hits: 3, Misses: 10},
},
}, {
name: "reload-all d",
key: "d",
state: State{
Keys: []string{"a", "b", "c", "d"},
Stats: Stats{Hits: 3, Misses: 11},
},
}, {
name: "read a again",
key: "a",
state: State{
Keys: []string{"b", "c", "d", "a"},
Stats: Stats{Hits: 4, Misses: 11},
},
}, {
name: "read e, evicting b",
key: "e",
state: State{
Keys: []string{"c", "d", "a", "e"},
Stats: Stats{Hits: 4, Misses: 12},
},
},
}


Loading…
Cancel
Save