-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.go
More file actions
50 lines (41 loc) · 1.36 KB
/
models.go
File metadata and controls
50 lines (41 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package ascache
// PolicyType identifies a cache replacement policy.
type PolicyType uint
const (
Undefined PolicyType = iota
LRU
LFU
)
// MigrationStrategy controls how key/value pairs are transferred when the
// active policy changes.
type MigrationStrategy uint
const (
// MigrationCold starts the new active policy from an empty state. This is
// the simplest strategy but causes a temporary cache-miss spike after every
// policy switch.
MigrationCold MigrationStrategy = iota
// MigrationWarm copies all key/value pairs from the old active policy into
// the new active policy at switch time. Shadow zero-value entries in the
// target policy are purged first so that only real values are served.
MigrationWarm
// MigrationGradual lazily drains the old active policy into the new one.
// Each Get() miss attempts to promote the key from the old policy; each
// Add() call migrates one additional key. The migration window closes at
// the next epoch boundary, on Purge(), or when all keys have been drained.
MigrationGradual
)
// GlobalStats holds aggregate hit/miss statistics exposed to callers.
type GlobalStats struct {
Hits int64
Misses int64
}
type PolicyStats struct {
Hits int64
Misses int64
}
// ShadowStats holds the hit/miss result of a shadow cache sensor for one epoch.
type ShadowStats struct {
Policy PolicyType
Hits int64
Misses int64
}