@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

iOS原生数据存储策略的更多相关文章

  1. IOS开发数据存储篇—IOS中的几种数据存储方式

    IOS开发数据存储篇—IOS中的几种数据存储方式 发表于2016/4/5 21:02:09  421人阅读 分类: 数据存储 在项目开发当中,我们经常会对一些数据进行本地缓存处理.离线缓存的数据一般都 ...

  2. iOS 应用数据存储方式(XML属性列表-plist)

    iOS 应用数据存储方式(XML属性列表-plist) 一.ios应用常用的数据存储方式 1.plist(XML属性列表归档) 2.偏好设置 3.NSKeydeArchiver归档(存储自定义对象) ...

  3. iOS开发UI篇—ios应用数据存储方式(XML属性列表-plist)

    iOS开发UI篇—ios应用数据存储方式(XML属性列表-plist) 一.ios应用常用的数据存储方式 1.plist(XML属性列表归档) 2.偏好设置 3.NSKeydeArchiver归档(存 ...

  4. iOS开发UI篇—ios应用数据存储方式(偏好设置)

    iOS开发UI篇—ios应用数据存储方式(偏好设置) 一.简单介绍 很多iOS应用都支持偏好设置,比如保存用户名.密码.字体大小等设置,iOS提供了一套标准的解决方案来为应用加入偏好设置功能 每个应用 ...

  5. iOS开发UI篇—ios应用数据存储方式(归档)

    iOS开发UI篇—ios应用数据存储方式(归档)  一.简单说明 在使用plist进行数据存储和读取,只适用于系统自带的一些常用类型才能用,且必须先获取路径相对麻烦: 偏好设置(将所有的东西都保存在同 ...

  6. iOS本地数据存储(转载)

    看到一篇不错的文章,推荐给大家!!! 应用沙盒 1)每个iOS应用都有自己的应用沙盒(应用沙盒就是文件系统目录),与其他文件系统隔离.应用必须待在自己的沙盒里,其他应用不能访问该沙盒 2)应用沙盒的文 ...

  7. iOS应用数据存储的常用方式

    iOS应用 数据存储的常用方式 XML属性列表 plist Preference 偏好设置 NSKeyedArchiver 归档 Core Data SQLite3 应用沙盒: Layer:     ...

  8. iOS开发技术分享(1)— iOS本地数据存储

    iOS开发技术分享(1)— iOS本地数据存储 前言: 我本是一名asp.net程序员,后来加入了iOS游戏开发队伍,到现在也有一年多的时间了.这一年来,每天都干到2.3点钟才睡觉,不为别的,只为了学 ...

  9. iOS开发UI篇—ios应用数据存储方式(归档) :转发

    本文转发至:文顶顶http://www.cnblogs.com/wendingding/p/3775293.html iOS开发UI篇—ios应用数据存储方式(归档)  一.简单说明 在使用plist ...

随机推荐

  1. Python的基础知识01 _个人笔记

    1.快捷键:Alt+n 回到上一条语句>把上一条语句复制 Alt+p  去到下一条语句 2.Python 中不用“:”来表示一个语句 3.print("I Love you" ...

  2. POJ 2395 Out of Hay( 最小生成树 )

    链接:传送门 题意:求最小生成树中的权值最大边 /************************************************************************* & ...

  3. ZOJ 3874 Permutation Graph (分治NTT优化DP)

    题面:vjudge传送门 ZOJ传送门 题目大意:给你一个排列,如果两个数构成了逆序对,就在他们之间连一条无向边,这样很多数会构成一个联通块.现在给出联通块内点的编号,求所有可能的排列数 推来推去容易 ...

  4. 「Poetize4」创世纪

    在tyvj上怀疑爆栈了.....或许一定是我写挂了.以后调吧... UPD:bzoj上过了... 题解:https://blog.csdn.net/popoqqq/article/details/39 ...

  5. vue v-for下图片src显示失败,404错误

  6. 深入了解Spring中的容器

    1.创建Bean的3种方式 1.1使用构造器创建bean实例 这是最常见的方式,如果不采用构造注入,bean类需要有默认构造函数.如果采用构造注入,则需要配置xml文件的<constructor ...

  7. ElasticSearch[v6.2] 在实际项目中的应用

    摘要:本文所讲述的内容,为ElasticSearch(以下简称ES)全文搜索引擎在实际大数据项目的应用:ES的底层是开源库 Lucene.但是,你没法直接用 Lucene,必须自己写代码去调用它的接口 ...

  8. nodejs-配置vs code的插件

    在windows上安装好npm后,再在终端里使用npm安装express,再安装express-generator  进入express的目录, 在终端中执行 npm install 启动expres ...

  9. C#中的public protected internal private

    1.常见的四种方位修饰符关系下图中的protected internal是并集的关系,意思是在命名空间内是internal的,在命名空间外是protected的 2.sealed final seal ...

  10. Android ViewGroup拦截触摸事件具体解释

    前言 在自己定义ViewGroup中.有时候须要实现触摸事件拦截.比方ListView下拉刷新就是典型的触摸事件拦截的样例. 触摸事件拦截就是在触摸事件被parent view拦截,而不会分发给其ch ...