Latest 0.5.0
Homepage https://github.com/DanielTomlinson/Stash
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0
Authors

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

Latest podspec

{
    "name": "Stash",
    "version": "0.5.0",
    "summary": "A parallel object cache for Swift 2.0",
    "description": "Stash is a key/value store for temporarily persisting objects, such as network responses (images etc), or expensive to reproduce values.n`Stash` is a simple object that wraps `Memory` (a fast in memory store) and `Disk` (a slower, file system backed store).n`Memory` will automatically clear itself when your app receives a memory warning.n`Disk` will persist items until you manually remove items, or automatically using limits.nThe caches will accept any object that conforms to `NSCoding`, although I'm open to considering a different encoding.nThe caches primary API's are synchronous, although there are asynchronous wrappers around most of them.",
    "homepage": "https://github.com/DanielTomlinson/Stash",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Daniel Tomlinson": "[email protected]"
    },
    "social_media_url": "http://twitter.com/DanToml",
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/DanielTomlinson/Stash.git",
        "tag": "0.5.0"
    },
    "source_files": [
        "Source",
        "Stash/*.swift"
    ]
}

Pin It on Pinterest

Share This