SamSaffron / lru_redux

An efficient optionally thread safe LRU Cache
MIT License
285 stars 20 forks source link

LruRedux::TTL::ThreadSafeCache.delete does not return the deleted item as docs say #22

Open adam-hampton-sp opened 1 year ago

adam-hampton-sp commented 1 year ago

The LruRedux::TTL::ThreadSafeCache.delete method does not return the deleted item as docs say. It looks like the code returns an expiration time float value and not the deleted item.

Easy enough to work around, but we need to either update the README docs or change the library's behavior.

Example reproduction:

my_cache = LruRedux::TTL::ThreadSafeCache.new(8, 300)
my_cache["a"] = "This is string A"
my_cache["b"] = "This is string B"

result_obj = my_cache.delete "a"
puts "result_obj: #{result_obj} #{result_obj.class}"

This produces output like:

result_obj: 1697043228.1882849 Float