Closed gabors closed 4 years ago
EDIT: even with saving to cache with .date() Expiry some of the API behave inconsistently.
Here is my testing:
myCache.entry(ofType: String.self, forKey: key) would find the entry in the cache (unless I just called removeExpiredObjects()) and the entry would correctly show isExpired as true.
OTH, when I call myCache.existsObject(ofType: String.self, forKey: key) this would return true, which is unexpected.
ALSO! calling myCache.object(ofType: String.self, forKey: key) also finds the value in the cache even though it is expired. Very unexpected.
@gabors Hi, I wonder if this fixes your issue https://github.com/hyperoslo/Cache/pull/176 ?
Hi @onmyway133, the code reads
case .seconds(let seconds):
return Date().addingTimeInterval(seconds)
Then obviously if we call isExpired
lately, the item will never get expired because the resulting date will be always greater than .now()
.
@onmyway133 the same problem for me ,you fix it ?
Recently I found that when saving a Codable into a cache that is configured to use Expiry .seconds() will never make the cache item expire. Every time I fetch an entry from the cache the expiry.date shows the current date + seconds, and therefore isExpired is always false.
When I save using the Expiry .date() entries expire as expected.