From 7f9a513ea1803af327067b7bd84326c63b3d3844 Mon Sep 17 00:00:00 2001 From: Marc Pervaz Boocha Date: Mon, 3 Mar 2025 17:24:17 +0530 Subject: Added documentation and tests --- evict.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'evict.go') 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() -- cgit v1.2.3-70-g09d2