Commit 504c6b4 1 parent 8efabe9 commit 504c6b4 Copy full SHA for 504c6b4
File tree 1 file changed +3
-8
lines changed
1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -68,24 +68,19 @@ func (build Builder) WithEvictionCallback(cb EvictionCallback) Builder {
68
68
69
69
// WithCapacity configures the cache with specified capacity.
70
70
//
71
- // If cache exceeds the limit, the eldest record is evicted.
71
+ // If cache exceeds the limit, the eldest record is evicted or
72
+ // if LFU is enabled, the least frequently used record is evicted.
72
73
func (build Builder ) WithCapacity (capacity uint32 ) Builder {
73
74
return func (c * Cache ) {
74
75
build (c )
75
76
c .list = newRingList (capacity )
76
77
}
77
78
}
78
79
79
- // WithLFU enables the eventual LFU ordering of records.
80
- //
81
- // New records are inserted as the most frequently used to
82
- // reduce premature eviction of new but unused records.
80
+ // WithLFU enables eventual LFU ordering of records.
83
81
func (build Builder ) WithLFU () Builder {
84
82
return func (c * Cache ) {
85
83
build (c )
86
- if c .list == nil {
87
- panic ("evcache: WithLFU requires WithCapacity" )
88
- }
89
84
c .lfuEnabled = true
90
85
}
91
86
}
You can’t perform that action at this time.
0 commit comments