Swiftpack.co - MountainBuffalo/Cacher as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MountainBuffalo.
MountainBuffalo/Cacher 2.0.0
Cacher made in swift
⭐️ 23
🕓 2 years ago
.package(url: "https://github.com/MountainBuffalo/Cacher.git", from: "2.0.0")

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!

GitHub

link
Stars: 23
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

Version 2.0.0
6 years ago

After the major refactor, Cacher now has memory cache limits, disk cache limits and is Swift 4

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics