aboutsummaryrefslogtreecommitdiffstats
path: root/evict.go
diff options
context:
space:
mode:
authorMarc Pervaz Boocha <marcpervaz@qburst.com>2025-03-03 17:24:17 +0530
committerMarc Pervaz Boocha <marcpervaz@qburst.com>2025-03-03 17:24:17 +0530
commit7f9a513ea1803af327067b7bd84326c63b3d3844 (patch)
treed0fd50db0aa8d4d59a79c22fc9eb9b84e305a261 /evict.go
parentImproved Concurency (diff)
downloadcache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar.gz
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar.bz2
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar.lz
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar.xz
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.tar.zst
cache-7f9a513ea1803af327067b7bd84326c63b3d3844.zip
Added documentation and tests
Diffstat (limited to '')
-rw-r--r--evict.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/evict.go b/evict.go
index 6b0aabc..eff626c 100644
--- a/evict.go
+++ b/evict.go
@@ -41,6 +41,8 @@ func pushEvict(node *node, sentinnel *node) {
node.EvictPrev.EvictNext = node
}
+var ErrInvalidPolicy = errors.New("invalid policy")
+
// SetPolicy sets the eviction policy based on the given type.
func (e *evictionPolicy) SetPolicy(y EvictionPolicyType) error {
store := map[EvictionPolicyType]func() evictionStrategies{
@@ -63,7 +65,7 @@ func (e *evictionPolicy) SetPolicy(y EvictionPolicyType) error {
factory, ok := store[y]
if !ok {
- return errors.New("invalid policy")
+ return ErrInvalidPolicy
}
e.evictionStrategies = factory()