hyperoslo / Cache

:package: Nothing but Cache.
Other
2.96k stars 335 forks source link

Improve dealing with cache expiration #308

Closed Alkenso closed 5 months ago

Alkenso commented 1 year ago

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

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)
        }
    }
}
3lvis commented 1 year ago

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 commented 5 months ago

Closing, reason outdated issue.