如果NSURLCache已满怎么办?

如果NSURLCache已满怎么办?

问题描述:

我正在使用默认的NSURLCache在iPhone应用程序中缓存图像. 如果缓存已满,我将尝试缓存另一个图像会发生什么情况?

I'm using default NSURLCache to cache images in my iPhone app. What will happen if the cache is full and i'll try to cache another image?

是否不缓存图像?还是将其替换为最早的缓存图像?

Will it not cache the image? or it will be replaced with the oldest image cached?

非常感谢

初始化可能会影响最大缓存 initWithMemoryCapacity:... diskCapacity:... diskPath:..] 新文件将始终被下载. (除非它大于最大内存容量,否则它将仅被下载而不保存在缓存中) 如果达到最大高速缓存大小,则将删除其他文件. 没有指定要删除的文件. 创建自己的NSUrlCache并自己处理它并不难. 如果您想查看一个示例,请查看 https://github.com/evermeer/EVURLCache

The maximum cache can be influenced with the initialization initWithMemoryCapacity:... diskCapacity:... diskPath:..] The new file will always be downloaded. (except when it's bigger than the maximum memory capacity, then it will just be downloaded and not saved in the cache) If the maximum cache size is reached other file(s) will be removed. It is not specified what files will be removed. It's not difficult to create your own NSUrlCache and handle it yourself. if you want to see a sample how to do that, then have a look at https://github.com/evermeer/EVURLCache