nebhale / CacheCache

A simple, lightweight, and extensible caching framework for Swift-based applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CacheCache

Carthage compatible Build Status

CacheCache is intended to be a simple, lightweight, and extensible caching framework for Swift-based applications.

Installation

Carthage is the easiest way to use this framework. Follow the Carthage instructions to add a framework to your application. The proper declaration for your Cartfile is:

github "nebhale/CacheCache"

Usage

To use CacheCache, first start by importing the module. Next, create a new instance of the one of the Cache implementations. In most cases, using the PropertyListCache is correct. This creates a Cache that will write content to a property list in the .CachesDirectory of the filesystem. Finally, call the persist() and retrieve() methods to access the cache.

import CacheCache

final class Example {

    private let cache = PropertyListCache<[String : String]>("example-type")

    func example() {
        let expected = ["test-key" : "test-value"]

        self.cache.persist(payload) { return $0 }
        let actual = self.cache.retrieve { return $0 as? Dictionary }

        println(actual == expected)
    }
}

Contributing

Pull requests are welcome.

License

This project is released under version 2.0 of the Apache License.

About

A simple, lightweight, and extensible caching framework for Swift-based applications

License:Apache License 2.0


Languages

Language:Swift 100.0%