什么时候应该删除iPhone应用程序中的缓存数据? [英] When should we delete the cache data in an iPhone apps?

查看:68
本文介绍了什么时候应该删除iPhone应用程序中的缓存数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们经常缓存图像和数据,以提高iPhone应用程序的性能。但是,您使用什么策略来管理高速缓存数据,例如删除或更新高速缓存数据呢?

We often cache image and data to improve our iPhone app's performance. But what strategy do you use to manage the cache data, such as delete or update it?

我将图像保存到TMP文件夹中,但是不知道何时应该触发检查过期的缓存数据并删除它:iPhone应用程序何时启动,退出或处于空闲时间?

I saved the images to TMP folder, but don't know when should I trigger to "checking out of date cache data and delete it": when the iPhone apps starts, or quits, or in idle time?

推荐答案

感谢您的回答。
我同意在开始或退出时检查是否删除缓存会降低程序的性能。此外,退出时间还用于保存程序的状态。

Appreciate for your responses. I agree that checking for delete the cache at the start or quit time will reduce the program's performance. Moreover, quit time is also used for saving the program's state.

在1分钟内检查空闲时间的想法还可以,但是我必须建立一种机制来检查在应用时间内每15秒空闲一次。我认为这并不容易且对性能没有好处。

The idea to check for idle time in 1 min is quite ok, but I have to build mechanism to check idle for every 15 s during the application time. I don't think it's easy and good for performance.

最后,我决定在检索新项目(数据和图像)后执行检查并删除缓存 。我将检查不再需要显示的项目(数据+图片)并将其删除。我认为保存缓存的功能也将删除缓存是有道理的。
当然,我将在另一个线程中执行此操作,以避免冻结接口。

At last, I decide to perform "check and delete cache" after I retrieve new Items (data + image). I will check for items (data +image) that doesn't need to be displayed anymore and delete it. I think it makes sense that the feature who saves the cache, will deletes the cache also. Certainly, I will do this in another thread to avoid frozen the interface.

这样好吗?请给我您的意见。

Is this good? Pls give me your opinions.

这篇关于什么时候应该删除iPhone应用程序中的缓存数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆