Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用NSCache 保存NSURLSessionDataTask,内存不足时会不会被清掉,用NSDictionary不更好吗? #31

Open
tljackyi opened this issue May 20, 2016 · 2 comments

Comments

@tljackyi
Copy link

No description provided.

@aozhimin
Copy link
Contributor

@tljackyi 恩,是的,内存吃紧的时候,NSCache中的缓存数据会被删掉,这也是他与NSDictionary的区别,正是这种自动删除的策略和高效使其适合缓存短时间使用但创建昂贵的对象,这里的AFHTTPSessionManager正是这种使用场景,即使由于低内存警告,NSCache缓存的数据删掉了也没关系,SessionManager会被重新创建,综上,NSCache更好。

@tljackyi
Copy link
Author

@aozhimin 那cancelAPIRequest:的时候,恰好sessionTasksCache自动删除了该DRDBaseAPI保存NSURLSessionDataTask,会不会出现无法cancel task。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants