Swiftpack.co - cozzin/Cache as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
cozzin/Cache
💾 Simple memory & disk cache
.package(url: "https://github.com/cozzin/Cache.git", from: "1.0.0")

Cache

💾 Simple memory & disk cache

Usage

🧑‍💻 Default

let cache = Cache<String>()

try memory.save("MyValue", forKey: "MyKey")

let cached = try cache.value(forKey: "MyKey")

🚀 Advanced

You can also use custom object with Codable

struct CustomObject: Codable {
    let value: Int
}

let memory = MemoryCache<CustomObject>(countLimit: 100)
let disk = DiskCache<CustomObject>(fileManager: fileManager)
let cache = Cache<CustomObject>(memory: memory, disk: disk)

try cache.save(CustomObject(value: 0), forKey: "MyKey")

let cached = try cache.value(forKey: "MyKey")

♻️ Flow

Load value

  1. Load memory cache if available
  2. Load disk cache if available 2-1. then, save to memory cache if value existed in disk cache

Save value

  1. Save memory & cache

🧰 Installation

  1. In your Xcode project, navigate to File > Swift Packages > Add Package Dependancy...
  2. Paste the following into the URL field: https://github.com/cozzin/Cache

GitHub

link
Stars: 1
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

1.0.0
2 weeks ago

Simple memory & disk cache

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics