@interface NSCache : NSObject

Description

A mutable collection you use to temporarily store transient key-value pairs that are subject to eviction when resources are low.

Cache objects differ from other mutable collections in a few ways:

  • The NSCache class incorporates various auto-eviction policies, which ensure that a cache doesn’t use too much of the system’s memory. If memory is needed by other applications, these policies remove some items from the cache, minimizing its memory footprint.
  • You can add, remove, and query items in the cache from different threads without having to lock the cache yourself.
  • Unlike an NSMutableDictionary object, a cache does not copy the key objects that are put into it.

You typically use NSCache objects to temporarily store objects with transient data that are expensive to create. Reusing these objects can provide performance benefits, because their values do not have to be recalculated. However, the objects are not critical to the application and can be discarded if memory is tight. If discarded, their values will have to be recomputed again when needed.

Objects that have subcomponents that can be discarded when not being used can adopt the NSDiscardableContent protocol to improve cache eviction behavior. By default, NSDiscardableContent objects in a cache are automatically removed if their content is discarded, although this automatic removal policy can be changed. If an NSDiscardableContent object is put into the cache, the cache calls discardContentIfPossible on it upon its removal.

只是内存存储,要与文件存储系统联合使用。

参考SDImage;

@interface NSURLCache : NSObject

Description

An object that maps URL requests to cached response objects.

The NSURLCache class implements the caching of responses to URL load requests by mapping NSURLRequest objects to NSCachedURLResponse objects. It provides a composite in-memory and on-disk cache, and lets you manipulate the sizes of both the in-memory and on-disk portions. You can also control the path where cache data is stored persistently.

Note

In iOS, the on-disk cache may be purged when the system runs low on disk space, but only when your app is not running.

文件与内存双重存储;存储策略为网络数据缓存策略。缓存的路径(首次引用NSURLCache会创建以下文件):

查看方式:cat命令。

问题:request会在处理过程成发生变化。

@interface NSUserDefaults : NSObject
Description

An interface to the user’s defaults database, where you store key-value pairs persistently across launches of your app.

The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an app to customize its behavior to match a user’s preferences. For example, you can allow users to specify their preferred units of measurement or media playback speed. Apps store these preferences by assigning values to a set of parameters in a user’s defaults database. The parameters are referred to as defaults because they’re commonly used to determine an app’s default state at startup or the way it acts by default.

At runtime, you use NSUserDefaults objects to read the defaults that your app uses from a user’s defaults database. NSUserDefaults caches the information to avoid having to open the user’s defaults database each time you need a default value. When you set a default value, it’s changed synchronously within your process, and asynchronously to persistent storage and other processes.

存储方式为本质存储;

路径:

NSKeyedArchiver

NSCoding (NSKeyedArchiver\NSKeyedUnarchiver)  (能把任何对象都直接保存成文件的方式)

- (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile;
Description

Writes the data object's bytes to the file specified by a given path.

This method may not be appropriate when writing to publicly accessible files. To securely write data to a public location, use NSFileHandle instead. For more information, seeSecuring File Operations in Secure Coding Guide.

coredata

最新文章

  1. 高性能JavaScript 加载和执行
  2. 自制公众平台Web Api(微信)
  3. ajax contenttype
  4. 《Apache服务之php/perl/cgi语言的支持》RHEL6——服务的优先级
  5. javascript GB2312转UTF8
  6. 类库探源——System.Delegate
  7. 两种动态载入修改后的python模块的方法
  8. 完成端口(Completion Port)详解(超级长,超级清楚)
  9. JAVA中字符串函数subString的用法小结
  10. YII 1.0模型标签与验证规则,前后台验证
  11. let内嵌lambda使用set!构成闭包
  12. C语言可变参数
  13. 集腋成裘-09-ECharts -HelloECharts-02
  14. ArcGIS为面要素生成邻接矩阵
  15. Google Analytics电子商务篇(Universal版)
  16. react 中子组件调用父组件的方法
  17. MDK-ARM输出HEX文件重命名设置
  18. mysql学习(2)-Navicat Premium 12 链接MySQL8.0.11数据库报2059错误
  19. MVC教程六:视图的寻址
  20. SharePoint自动化系列——通过PowerShell创建SharePoint Web

热门文章

  1. cordova 打包工具
  2. 怎么看时序图--nand flash的读操作详解 (转)
  3. anaconda下jieba和wordcloud安装
  4. kernel对NTP的API,系统调用函数
  5. 3.2、使用Flask-Bootstrap集成Twitter Bootstrap
  6. FreeMarker 语法 date 类型处理
  7. soapui测试接口使用步骤
  8. test environment bug
  9. 用户体验之如何优化你的APP
  10. python 学习笔记 12 -- 写一个脚本获取城市天气信息