/TinyCache

Simple and lightweight caching solution for Swift apps.

Primary LanguageSwiftMIT LicenseMIT

TinyCache

TinyCache is a simple and lightweight caching solution for Swift apps.

Installation

Swift Package Manager

To integrate TinyCache into your project using Swift Package Manager, add it to your Package.swift file:

dependencies: [
    .package(url: "https://github.com/skyfe79/TinyCache.git", .upToNextMajor(from: "0.0.1"))
]

Usage

Memory Caching

let tinyCache = TinyCache<String, String>(policy: .default)
tinyCache.set(value: "Hello, World!", forKey: "greeting")
let greeting = tinyCache.value(forKey: "greeting")

Codable Caching

struct MyModel: Codable {
    let id: Int
    let name: String
}

let codableCache = TinyCodableCache.shared
let model = MyModel(id: 1, name: "TinyCache")
codableCache.set(codable: model, forKey: "modelKey")

Image Caching

let imageCache = TinyImageCache.shared
imageCache.set(image: myImage, forKey: "imageKey")

License

TinyCache is released under the MIT License. See LICENSE for details.