NSCache是​​否在两次启动之间持续存在? [英] Does NSCache persist between launches?

查看:82
本文介绍了NSCache是​​否在两次启动之间持续存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一种相当简单的缓存机制,目前正在使用NSCache(出于内存管理的原因).问题是-缓存是否在两次启动之间持续存在?对我来说似乎不行.

I'm looking into a fairly simple mechanism for caching and and currently using NSCache (for the reason of memory management). Question is - does the cache persist between launches? It seems like no to me.

我可以将对象很好地放入缓存中,并且可以在应用程序运行时将它们从缓存中取出.但是一旦我重新启动,似乎缓存就消失了.

I get objects put in cache just fine and can take them out of the cache while the app is running no problem. But once I relaunch, seems like the cache is gone.

那么有没有一种方法可以使高速缓存在两次启动之间持久存在?如果是这样,您如何将缓存从上一个会话重新同步到当前会话?

So is there a way to make the cache persist between launches? If so, how would you re-sync the cache from previous session to the current?

推荐答案

NSCache不会在两次启动之间持久存在-如果您要保存缓存,我建议您仅保存使用CoreData读取数据-尽管如果内存管理是一个问题,那么也许您会节省太多.这确实取决于您要开发的内容.

NSCache does not persist between launches- if you'd like to save the cache, I'd recommend simply saving the data using CoreData- although if memory management is an issue, then perhaps you'd be saving too much. It truly depends on what you're developing.

这篇关于NSCache是​​否在两次启动之间持续存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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