Cache
Cache copied to clipboard
Improve dealing with cache expiration
First, I'm saying "thank you!" for great caching library! It eliminates lots of needs related to caching, especially for expirable entries
Next, I'd like to ask to add convenient extension to the library
- requesting object with checking if it is still alive
- scheduling cache cleanup
extension StorageAware {
public func aliveObject(forKey key: Key) -> Value? {
try? !isExpiredObject(forKey: key) ? object(forKey: key) : nil
}
public func scheduleCleanup(_ interval: TimeInterval) where Self: AnyObject {
DispatchQueue.global().asyncAfter(deadline: .now() + interval) { [weak self] in
try? self?.removeExpiredObjects()
self?.scheduleCleanup(interval)
}
}
}
Hi @Alkenso,
Thank you for using the library, unfortunately it's been some time since the library has been actively maintained and now we focus on fixes rather than additions.
Closing, reason outdated issue.