I have a pretty interesting iPhone app, and I want to store deleted downloaded images locally in the tmp directory in the app sandbox to avoid unnecessary network requests. Is there a limit on the total size of files stored in application directories, or should this application manage this? How does the application determine the size of the files in the tmp directory?
Also, if the application needs to control the size of the cache, I would like to implement some kind of cache policy to determine which files are getting invalid. How can I do it? If I want to implement the basic LRU caching policy - the invalid files that have been used recently, it seems that I will need to store access counts for each image and store them on disk, which also seems funny. My guess is that a simple size management policy would be to simply completely erase the cache every time the application terminates.
Also, what's the difference between using a directory from NSCachesDirectory and NSTemporaryDirectory? Both are mentioned in Apple docs, but donβt say which one should be used for which file types. I think NSTemporaryDirectory is more like a Unix / var / tmp directory and is used for ephemeral data that can be destroyed at any time. It seems to me that NSCachesDirectory is more suitable for storing cached images, since files may be needed for several application life cycles.
source share