Simple on disk cache, backed by an NSCache in memory. It automatically purges itself when memory gets low.
- Support all data types confirming to
Codable
protocol - Thread safe and optmised for fater caching
- Objects can be purged in case of low memory in the system
- iOS 10.0+
- Xcode 9+
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate SwifteeCache into your Xcode project using CocoaPods, specify it in your Podfile
:
platform :ios, '10.0'
use_frameworks!
pod 'SwifteeCache'
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.Create a Cartfile
that lists the framework and run carthage update
. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/SwifteeCache.framework
to an iOS project.
github "nikksindia/SwifteeCache"
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding SwifteeCache as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/nikksindia/SwifteeCache.git", .upToNextMajor(from: "1.1.0"))
]
If you prefer not to use any of the aforementioned dependency managers, you can integrate SwifteeCache into your project manually.
- Download and drop
SwifteeCache.swift
in your project. - Congratulations!
For adding/removing objects in cache:
func setObject<T:Codable>(_ object:T,forKey key:String)
func removeObjectForKey(_ key:String)
func removeAllObjects()
For fetching objects in cache:
func getObjectForKey<T:Codable>(_ key:String)->T?
func objectExistsForKey(_ key:String)->Bool
Build and run the Example
target. This is a simple implementation of the library that allows users to select fetch and store codable mock data in the cache.
The project includes a unit test and UI test target, providing coverage of the basic layout and functionality of the product. When adding a new feature, be sure to add unit tests and a basic layout test if applicable.
We would love you for the contribution to SwifteeCache, check the LICENSE
file for more info.
Nikhil Sharma – @devilnikks – nikksindia@gmail.com
Distributed under the MIT license. See LICENSE
for more information.