All Projects → hlc0000 → SwiftlyCache

hlc0000 / SwiftlyCache

Licence: MIT license
SwiftlyCache is a thread safe IOS general cache Library

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to SwiftlyCache

Cache
📦 Nothing but Cache.
Stars: ✭ 2,491 (+2865.48%)
Mutual labels:  memory-cache, cache-storage, disk-cache
CodablePersist
Store and Cache Anything Codable
Stars: ✭ 18 (-78.57%)
Mutual labels:  memory-cache, disk-cache
image-loader
Image loading library for Android
Stars: ✭ 19 (-77.38%)
Mutual labels:  memory-cache, disk-cache
ColdStorage
Lightweight data loading and caching library for android
Stars: ✭ 39 (-53.57%)
Mutual labels:  cache-storage
incache
Powerful key/value in-memory storage or on disk to persist data
Stars: ✭ 16 (-80.95%)
Mutual labels:  cache-storage
robin
robin provides a high performance golang goroutine library and job scheduling、in-memory cache for humans.
Stars: ✭ 28 (-66.67%)
Mutual labels:  memory-cache
cache
🗃 Generic cache use and cache manage. Provide a unified usage API by packaging various commonly used drivers. Support File, Memory, Redis, Memcached and more. Go 通用的缓存使用库,通过包装各种常用的驱动,来提供统一的使用API,便于使用。
Stars: ✭ 146 (+73.81%)
Mutual labels:  memory-cache
json-caching-proxy
Node caching HTTP proxy built on top of express-http-proxy. Persists requests and responses to an in-memory HAR-like data structure based on HAR1.2 . Caches JSON content-type responses by default with the ability to cache an entire site; including content-types describing images. Useful for testing front end code, mocking api, and saving the cac…
Stars: ✭ 31 (-63.1%)
Mutual labels:  cache-storage
simple-cache
⚡ Simple Cache Abstraction Layer for PHP
Stars: ✭ 28 (-66.67%)
Mutual labels:  cache-storage
.NetCorePluginManager
.Net Core Plugin Manager, extend web applications using plugin technology enabling true SOLID and DRY principles when developing applications
Stars: ✭ 17 (-79.76%)
Mutual labels:  memory-cache
hybrid-disk-cache
A hybrid disk cache library that utilized both the solid SQLite3 and file system.
Stars: ✭ 19 (-77.38%)
Mutual labels:  disk-cache
memcacher
C++ implementation of Memcache Binary Protocol.
Stars: ✭ 16 (-80.95%)
Mutual labels:  memory-cache
DTC
DTC is a high performance Distributed Table Cache system designed by JD.com that offering hotspot data cache for databases in order to reduce pressure of database and improve QPS.
Stars: ✭ 21 (-75%)
Mutual labels:  cache-storage
easy cache
Caching and invalidation have never been so easy
Stars: ✭ 28 (-66.67%)
Mutual labels:  cache-storage
cache
Laravel & Lumen Cache Service | File and Redis cache system
Stars: ✭ 19 (-77.38%)
Mutual labels:  cache-storage
quill-cache
Caching layer overtop Quill for Scala
Stars: ✭ 24 (-71.43%)
Mutual labels:  cache-storage
libcache
A caching library that provides an in-memory and file based cache for Ruby
Stars: ✭ 25 (-70.24%)
Mutual labels:  memory-cache
micro-cacheable
A micro utility for data caching
Stars: ✭ 35 (-58.33%)
Mutual labels:  cache-storage
affilicats
🐈 Progressive Web App demo that showcases flaky network resilience measures (📶 or 🚫📶).
Stars: ✭ 65 (-22.62%)
Mutual labels:  cache-storage
mysqly
Full-featured opensource small-overhead PHP data framework for Mysql built for fast and efficient development
Stars: ✭ 18 (-78.57%)
Mutual labels:  cache-storage

SwiftlyCache

Build Status

Swiftlycache is a thread safe IOS general cache library written with swift 5.

Features

  • Support all data types complying with the codable protocol
  • Objects can be evicted with least-recently-used algorithm
  • It can be configured to automatically recycle objects or manually recycle objects when receiving memory warnings or when the application enters the background
  • Using subscript can make reading and writing data more convenient
  • Support reading data using sequence generator

Installation

CocoaPods

1.Add pod 'SwiftlyCache' to your Podfile
2.Run 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)

设置需要缓存的KeyValue

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实现

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].