One of the handiest features of AwesomeCache is how it can help cache API responses (or any async code really). Here's how it works:

cache.setObjectForKey("photos.all",cacheBlock:{success,failureinself.requestLatestPhotos({responseinsuccess(response,.Seconds(300))},failure:{errorinfailure(error)})},completion:{object,isLoadedFromCache,errorinifletobject=object{// object is now cached, and ready to use}})

If a value already exists in the cache for the given key, the completion** closure** is called right away. Otherwise, the cacheBlockclosure is called. Inside the cacheBlock we call our custom own API code, then tell AwesomeCache if we succeeded or failed.