GithubHelp home page GithubHelp logo

korune / kocachefilemanagedemo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.36 MB

简单的缓存文件管理Demo。当缓存文件的大小超过最大缓存文件大小,按时间排序删除最早的文件。

License: MIT License

Objective-C 100.00%
filemanage cache-storage ios-demo

kocachefilemanagedemo's Introduction

KOCacheFileManageDemo

使用场景

  1. 在 App 启动的时候,扫描缓存目录。如果当前的缓存文件总大小,大于缓存文件的最大大小,则按比例删除时间比较早的缓存文件。
  2. 加载文件的时候,首先从缓存目录中加载文件。如果有则加载缓存文件,如果没有则下载文件。每次下载文件完成后,都判断缓存文件的总大小。如果大于缓存文件的最大大小,则按比例删除时间比较早的缓存文件。

实现思路

  1. 使用 KOCacheFile 模型保存文件信息。
  2. 使用 NSMutableSet 来判断保存的文件是否重复、存在。

API 的使用

使用 KOCacheFileManger 的下列方法:

+ (KOCacheFileManger *)sharedManger;

- (void)handleCacheFileOverSize;

- (void)saveCachePhotoInfo:(KOCacheFile *)cachePhoto
success:(void(^)())success
failure:(void(^)())failure;

- (void)deleteCachePhotoInfo:(KOCacheFile *)cachePhoto
success:(void(^)())success
failure:(void(^)())failure;

备注

如果只在 App 启动的时候,进行文件缓存管理。那么 KOCacheFileManger 可以不写成单例类,可以删除 - (void)saveCachePhotoInfo: success: failure:- (void)deleteCachePhotoInfo: success: failure: 两个方法,其他进行细节修改即可。

kocachefilemanagedemo's People

Contributors

korune avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.