https://github.com/song-react/cache
A light weight & high performance cache for iOS, macOS, tvOS and watchOS
https://github.com/song-react/cache
apple cache carthage ios macos swift tvos watchos
Last synced: about 2 months ago
JSON representation
A light weight & high performance cache for iOS, macOS, tvOS and watchOS
- Host: GitHub
- URL: https://github.com/song-react/cache
- Owner: song-react
- License: mit
- Created: 2017-08-03T13:37:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-09-10T14:59:28.000Z (almost 8 years ago)
- Last Synced: 2026-01-14T10:30:30.702Z (5 months ago)
- Topics: apple, cache, carthage, ios, macos, swift, tvos, watchos
- Language: Swift
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README







[](https://paypal.me/DingSongwen)
### 安装
#### Carthage
add code below to your Cartfile and command `carthage update`
```shell
github "DingSoung/Cache"
```
#### Swift Package Manager
follow the [SPMExample](https://github.com/DingSoung/SPMExample), UIKit excluded
```swift
import PackageDescription
let package = Package(
name: "SPMExample",
dependencies: [
.Package(url: "https://github.com/DingSoung/Cache.git", Version(0,4,0)),
]
)
```
### 缓存设计
* 线程安全
* 支持读写
* 写入自动创建文件夹
* 支持删除单个文件或目录
* 支持内存加速
* 支持读取失败回调(延迟)
* 支持返回写、删失败详情信息
### 用法
```objective-c
UserModel *user = [UserModel cacheForKeyPath:@"/users/uid03879658" fail:^(NSError * _Nonnull error) {
NSLog(@"%@", error);
}];
NSError *err1 = [UserModel removeCacheForKeyPath:@"/users/uid03879658"];
NSError *err2 = [UserModel removeCacheForPath:@"/users"];
```
高级用法参考[这里](https://github.com/DingSoung/Example)