Swiftpack.co - endocrimes/Stash as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by endocrimes.
endocrimes/Stash 0.5.0
A parallel object cache for Swift 2.0
⭐️ 23
🕓 4 years ago
.package(url: "https://github.com/endocrimes/Stash.git", from: "0.5.0")

Stash

Travis Build Status

Stash is a parallel object cache for Swift. It's based on TMCache.

Stash is a key/value store for temporarily persisting objects, such as network responses (images etc), or expensive to reproduce values.

Stash is a simple object that wraps Memory (a fast in memory store) and Disk (a slower, file system backed store). Memory will automatically clear itself when your app receives a memory warning. Disk will persist items until you manually remove items, or automatically using limits.

The caches will accept any object that conforms to NSCoding, although I'm open to considering a different encoding.

The caches primary API's are synchronous, although there are asynchronous wrappers around most of them.

Usage

Stash provides a relatively simple sync API, that can be used like so:

let stash = try! Stash(name: "MyCache", rootPath: NSTemporaryDirectory())

let image = UIImage(...)
stash["MyKey"] = image

let retreivedImage = stash["MyKey"] as? UIImage

and an async API:

let stash = try! Stash(name: "MyCache", rootPath: NSTemporaryDirectory())

let image = UIImage(...)
stash.setObject(image, forKey: "MyKey") { cache: Stash in
    // It's Done!!!
}

// Some time later, to access
stash.objectForKey("MyKey") { cache, key, value in
    let image = value as? UIImage
}

Installation

CocoaPods

Add pod Stash to your Podfile, and run pod install

Swift Package Manager

Add this repository to your Package.swift, and run swift build

GitHub

link
Stars: 23
Last commit: 4 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

8 years ago
  • Performance improvements when emptying memory caches
  • Performance improvements when doing removal operations

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