Delightful on-disk cache (written in Swift)
Compatibility for Swift 3.0
Fixes a bug that would lead to a crash if a new cache is created with the NSFileProtection
option (Thanks @niklassaers)
AwesomeCache 3 is designed to have a sync API, making it easy to reason about the actual contents of the cache. This decision has been made based on feedback from the community, to keep the API of AwesomeCache small and easy to use.
The internals of the cache use a concurrent dispatch queue, that syncs reads and writes for thread safety. In case a particular caching operation blocks your main thread for too long, consider offloading the read and write operations to a different thread.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
cache["name"] = "Alex"
}
Further improvements
objectForKey:
if present (#31)NSFileProtectionKey
value on the internal NSFileManager
. This may be necessary in case you observe odd behaviour when accessing the cache in the background. (#64)allObjects
from the cache (optionally, expired objects may be queried as well)NSURL
APIs instead of pathsobjectForKey
(thanks @alenofx)🚀
Rename AwesomeCache
class to Cache
.
(It is still as awesome as before. ✨)