Latest 0.1.0
License MIT
Platforms ios 8.3
Dependencies RxSwift



Example Usage

First create a class that implementes NSCoding and RxLiteCacheable protocols.

class Person: NSObject, NSCoding, RxLiteCacheable {
    let name: String
    init(name: String) { = name }

    func encode(with aCoder: NSCoder) {
        aCoder.encode(name, forKey: "name")

    required init?(coder aDecoder: NSCoder) { = aDecoder.decodeObject(forKey: "name") as! String

    var primaryKey: String { return name }

Create the cache that will hold those elements

let personCache: RxLiteCache<String, Person> = RxLiteCache(cacheName: "person", 
                                                           cacheTime: RxLiteCacheTime.minutes(5))

Remember in other to create a RxLiteCache<K,T> K must be Hashable and the primary key of T.

Now you are ready to go

let noel = Person(name: "Noel")
let noelFromOtherSource = Person(name: "Noel Gallagher")
personCache.add(firstPerson).subscribe()  //adds first person to cache 
personCache.get("Noel",                    //asks for person with identifier "Noel"
              source: Observable.just(secondPerson))  //in case of failure grabs it elsewhere
    .subscribe(onNext: { print($ })

This will print Noel. If you want to erase the item from the cache then:

personCache.removeKey(hasheable: "Noel")

Getting the idenfitier again will output "Noel Gallagher".

Latest podspec

    "name": "RxLiteCache",
    "version": "0.1.0",
    "summary": "RxSwift Cache.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Ivan Ruiz Monjo": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "platforms": {
        "ios": "8.3"
    "source_files": "RxLiteCache/**/*",
    "dependencies": {
        "RxSwift": [
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This