内容简介:1.Download all the files in the2.Add the source files to your Xcode project
SwiftlyCache
Swiftlycache
is a thread safe IOS general cache library written with swift 5
.
Features
codable
Installation
CocoaPods
1.Add pod 'SwiftlyCache'
to your Podfile
pod install
or pod update
3.import SwiftlyCache
Manually
1.Download all the files in the SwiftlyCache
subdirectory
2.Add the source files to your Xcode project
Example:
Cache a struct complying with the codable
protocol
struct Student:Codable {
var name:String
var age:Int
init(name:String,age:Int) {
self.name = name
self.age = age
}
}
let cache = MultiCache<Student>() let shirley = Student(name: "shirley", age: 30)
Set key
and value
to be cached
cache.set(forKey: "shirley10", value: shirley)
Query the corresponding value according to the given key
if let object = cache.object(forKey: "shirley1"){
print("当前Student是:\(object)")
}
Query whether the corresponding value
exists in the cache according to key
let isExists = cache.isExistsObjectForKey(forKey: "shirley20")
See swiftlycachedemo
for more test code and cases
中文介绍
SwiftlyCache
是用 Swift 5
编写的一个线程安全的iOS通用缓存库。
特性:
-
支持所有遵守
Codable协议的数据类型 - 支持LRU淘汰算法
- 当收到内存警告或者App进入后台时,内存缓存可以配置为自动清空或者手动清空
-
支持使用
Subscript,使读写数据更加方便 -
提供了
MultiCacheGennerator、MemoryCacheGenerator、DiskCacheGenerator用于支持for..in、compactMap、map、filter等方法
使用方法:
CocoaPods:
1.在Podfile中添加 pod 'SwiftlyCache'
2.执行 pod install
或者 pod update
3.导入 SwiftlyCache
手动导入:
1.下载 SwiftlyCache
文件夹内所有内容
2.将 SwiftlyCache
内的源文件添加到你的工程
示例:
将一个遵守 Codable
协议的struct进行缓存
struct Student:Codable {
var name:String
var age:Int
init(name:String,age:Int) {
self.name = name
self.age = age
}
}
let cache = MultiCache<Student>() let shirley = Student(name: "shirley", age: 30)
设置需要缓存的 Key
和 Value
cache.set(forKey: "shirley10", value: shirley)
根据给定的 Key
查询对应的Value
if let object = cache.object(forKey: "shirley1"){
print("当前Student是:\(object)")
}
根据 Key
查询缓存中是否存在对应的 Value
let isExists = cache.isExistsObjectForKey(forKey: "shirley20")
更多测试代码和用例见 SwiftlyCacheDemo
相关链接:
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- SwiftlyCache:线程安全的 iOS 通用缓存
- 高性能缓存服务器 nuster v1.8.8.1 支持 HTTP/2,多线程
- java中线程安全,线程死锁,线程通信快速入门
- ObjC 多线程简析(一)-多线程简述和线程锁的基本应用
- 轻松学会HTTP缓存(强缓存,协商缓存)
- Java多线程之线程中止
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
About Face 4: 交互设计精髓
[美] 艾伦·库伯、[美] 罗伯特·莱曼、[美] 戴维·克罗宁、[美] 克里斯托弗·诺埃塞尔 / 倪卫国、刘松涛、杭敏、薛菲 / 电子工出版社 / 2015-10 / 118.00元
《About Face 4: 交互设计精髓》是《About Face 3:交互设计精髓》的升级版,此次升级把全书的结构重组优化,更加精练和易用;更新了一些适合当下时代的术语和实例,文字全部重新编译,更加清晰易读;增加了更多目标导向设计过程的细节,更新了现行实践,重点增加 移动和触屏平台交互设计,其实《About Face 4: 交互设计精髓》多数内容适用于多种平台。 《About F......一起来看看 《About Face 4: 交互设计精髓》 这本书的介绍吧!