diff --git a/cache.go b/cache.go index d29c93d0..4e8e0dac 100644 --- a/cache.go +++ b/cache.go @@ -168,10 +168,16 @@ func NewCache[K Key, V any](config *Config[K, V]) (*Cache[K, V], error) { switch { case config.NumCounters == 0: return nil, errors.New("NumCounters can't be zero") + case config.NumCounters < 0: + return nil, errors.New("NumCounters can't be negative number") case config.MaxCost == 0: return nil, errors.New("MaxCost can't be zero") + case config.MaxCost < 0: + return nil, errors.New("MaxCost can't be be negative number") case config.BufferItems == 0: return nil, errors.New("BufferItems can't be zero") + case config.BufferItems < 0: + return nil, errors.New("BufferItems can't be be negative number") case config.TtlTickerDurationInSec == 0: config.TtlTickerDurationInSec = bucketDurationSecs }