Siegel 0.1.0

Siegel 0.1.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2015
SPMSupports SPM

Maintained by Mihyaeru.



Siegel 0.1.0

  • By
  • Mihyaeru

Siegel

A simple implementation of LRU cache written in Swift. This library is inspired by Cache::LRU.

Usage

let cache = Siegel<Int?>(size: 3)

// set
cache.set(key: "a", value: 1)
cache.set(key: "b", value: 2)
cache.set(key: "c", value: nil)
cache.set(key: "d", value: 4)
cache["s"] = 10

// get
cache.get(key: "a")      // => nil
cache.get(key: "b")      // => 2
cache.get(key: "c")      // => nil
cache.get(key: "4")      // => 4
cache["s"]               // => 10

// exists
cache.exists(key: "a")   // => false
cache.exists(key: "b")   // => true
cache.exists(key: "c")   // => true (if using optional type, it can contain nil)
cache.exists(key: "d")   // => true
cache.exists(key: "e")   // => false
cache.exists(key: "s")   // => true

// remove
cache.remove(key: "b")
cache.get(key: "b")      // => nil
cache.exists(key: "b")   // => false

// clear
cache.clear
cache.exists(key: "a")   // => false
cache.exists(key: "b")   // => false
cache.exists(key: "c")   // => false
cache.exists(key: "d")   // => false
cache.exists(key: "e")   // => false
cache.exists(key: "s")   // => false

Installation

Siegel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Siegel'

Author

Mihyaeru, [email protected]

License

Siegel is available under the MIT license. See the LICENSE file for more info.