美文网首页
NSURLCache

NSURLCache

作者: younger_times | 来源:发表于2017-11-28 16:36 被阅读91次

NSURLCache

  • Framework
    • Foundation
  • SDKs
    • iOS 8.0+
    • macOS 10.10+
    • tvOS 9.0+
    • watchOS 2.0+

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.
提供内存和磁盘缓存,操纵和分配在内存和磁盘的存储大小,你也可以控制存储的路径

在iOS中,当设备的磁盘空间不足时,在磁盘存储的数据将会被清理

线程安全

在iOS8+,macOS10.10+ NSURLCache是线程安全的。

@property(class, strong) NSURLCache *sharedURLCache;

返回NSURLCache实例

- (instancetype)initWithMemoryCapacity:(NSUInteger)memoryCapacity diskCapacity:(NSUInteger)diskCapacity diskPath:(NSString *)path;

初始化NSURLCache指定值,MemoryCapacitymemoryCapacity指定了缓存大小(bytes)diskPath指定磁盘位置

- (NSCachedURLResponse *)cachedResponseForRequest:(NSURLRequest *)request;

返回一个被缓存过的响应请求

- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse forRequest:(NSURLRequest *)request;

存储缓存的URL响应的请求。

- (void)getCachedResponseForDataTask:(NSURLSessionDataTask *)dataTask completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler;

No overview available.

- (void)storeCachedResponse:(NSCachedURLResponse *)cachedResponse forDataTask:(NSURLSessionDataTask *)dataTask;

No overview available.

- (void)removeCachedResponseForRequest:(NSURLRequest *)request;

清除缓存

- (void)removeCachedResponseForDataTask:(NSURLSessionDataTask *)dataTask;

No overview available.

- (void)removeCachedResponsesSinceDate:(NSDate *)date;

No overview available. 从什么时间开始清除缓存

- (void)removeAllCachedResponses;

No overview available. 移除所有缓存请求

@property(readonly) NSUInteger currentDiskUsage;

当前存储在磁盘中的存储大小,bytes字段

@property NSUInteger diskCapacity;

磁盘存储容量

@property(readonly) NSUInteger currentMemoryUsage;

当前存储在内存中的存储大小,bytes字段

@property NSUInteger memoryCapacity;

内存中存储容量


参考文

NSURLCache

相关文章

  • NSURLCache官方文档阅读

    NSURLCache Overview NSURLCache类通过将NSURLRequest对象映射到NSCach...

  • [iOS-Foundation] Networking Cach

    NSHipster-NSURLCache NSURLCache 通过保存NSURLRequest对象和其相应的NS...

  • iOS网络请求缓存 - NSURLCache

    NSURLCache NSURLCache为应用程序的URL请求提供复合的内存和磁盘缓存机制。作为Foundati...

  • NSCache & NSDictionary &

    NSCache和NSURLCache一点关系也没有 NSCache和NSURLCache一点关系也没有 NSURL...

  • NSURLCache

    NSURLCache 为应用的 URL 请求提供了内存以及磁盘上的缓存。当一个请求完成下载来自服务器的回应,一个缓...

  • NSURLCache

    cache1、afnetworking默认的NSURLSessionConfiguration 2、系统默认的NS...

  • NSURLCache

    概述 NSURLCache类通过将NSURLRequest对象映射到NSCached URLResponse对象来...

  • NSURLCache

    NSURLCache FrameworkFoundation SDKsiOS 8.0+macOS 10.10+tv...

  • NSURLCache

    NSURLCache为你的url请求提供了内存以及磁盘上的综合缓存机制。使用缓存可以减少向服务发送请求的次数,同时...

  • NSURLCache

    缘由 前一段时间去仿写SDWebImage的时候,就遇到这SDCache和NSURLCache,然后在类中还有地做...

网友评论

      本文标题:NSURLCache

      本文链接:https://www.haomeiwen.com/subject/agdebxtx.html