Skip to content

Commit

Permalink
Fix confusing error msg. during 2Q creation
Browse files Browse the repository at this point in the history
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 hashicorp#51
  • Loading branch information
rsjethani committed Sep 1, 2019
1 parent 7f827b3 commit ae46393
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 2q.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ae46393

Please sign in to comment.