Skip to content

Latest commit

 

History

History
91 lines (66 loc) · 2.03 KB

README.md

File metadata and controls

91 lines (66 loc) · 2.03 KB

build-badge codecov-badge license-badge

A simple general use cache written entirely in swift. Anything can be added to the cache as long as it subscribes to the Cacheable protocol, and anything as a key as long as it subscribes to CacheableKey protocol.

Features

  • Lightweight Caching generic
  • Does One Thing & Does It Well

Usage

Create a cache

let cache = Cache<String: Data>()

Add an item to a cache

let item = Data()
cache["MyItem"] = item

Get an item from cache

let cachedItem = cache["MyItem"]

Get an item from a url

cache.load(from: someUrl, key: "MyItem") { cachedItem, wasDownload, error in

}

Built in Image Cache

Add an item to a cache

let image = UIImage()
ImageCache.shared["MyItem"] = image

Get an item from cache

let cachedImage = ImageCache.shared["MyItem"]

Setting an image on an image view

imageView.set(url: someUrl)

Precaching

Downloading images right to cache for later use

let imagePrecher = ImagePrecher()
imagePrecher.get(urls: myUrls) { items, failedUrls in
  //Do something
}

Installation

CocoaPods

pod 'Cacher'

Carthage

github "MountainBuffalo/Cacher"

Contributing

If you wish to contribute to Cacher, please submit a pull request!

License

Cacher is licensed under the MIT License. As such, Casher is free for general usage, and would make an excellent addition to your next swift application!