Cache icon indicating copy to clipboard operation
Cache copied to clipboard

Improve dealing with cache expiration

Open Alkenso opened this issue 3 years ago • 1 comments

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)
        }
    }
}

Alkenso avatar Oct 17 '22 09:10 Alkenso

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.

3lvis avatar Oct 17 '22 21:10 3lvis

Closing, reason outdated issue.

3lvis avatar Mar 26 '24 05:03 3lvis