jellydator / ttlcache

An in-memory cache with item expiration and generics
MIT License
883 stars 115 forks source link

Add a method to check if a key exists #99

Closed lesichkovm closed 1 year ago

lesichkovm commented 1 year ago

The current way to check if a key exists is to use Get and check for nil. While it works it create boilerplate code.

It would be most convenient if there was a method to check if a key exists. For instance:

if cache.Has("key123") {
    return cache.Get("key123")
}

Thanks

swithek commented 1 year ago

That's a good idea :+1: