From ae46393b1ee3eb13fdad75eaced1d91eee20ad4d Mon Sep 17 00:00:00 2001 From: Ravi Shekhar Jethani Date: Sun, 1 Sep 2019 21:56:18 +0200 Subject: [PATCH] Fix confusing error msg. during 2Q creation For cases where the combination of 2Q size and ghostRatio result in evict cache of size 0, the error message displayed to the user is rather confusing. This commit proposes to fix the code and give a suitable error message to the user. Addresses: Issue #51 --- 2q.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2q.go b/2q.go index e474cd0..fdc3cae 100644 --- a/2q.go +++ b/2q.go @@ -70,7 +70,7 @@ func New2QParams(size int, recentRatio float64, ghostRatio float64) (*TwoQueueCa } recentEvict, err := simplelru.NewLRU(evictSize, nil) if err != nil { - return nil, err + return nil, fmt.Errorf("Failed to create Evict cache, please choose a higher 'ghostRatio' or increase cache 'size'") } // Initialize the cache