All Projects → soffes → Cache

soffes / Cache

Licence: mit
Swift caching library

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Cache

L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-15.71%)
Mutual labels:  tvos, watchos, carthage
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-34.29%)
Mutual labels:  tvos, watchos, carthage
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+479.05%)
Mutual labels:  tvos, watchos, carthage
Queuer
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).
Stars: ✭ 964 (+359.05%)
Mutual labels:  tvos, watchos, carthage
Diff
Simple diff library in pure Swift
Stars: ✭ 110 (-47.62%)
Mutual labels:  tvos, watchos, carthage
Color
Color utilities for macOS, iOS, tvOS, and watchOS
Stars: ✭ 145 (-30.95%)
Mutual labels:  tvos, watchos, carthage
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+520.48%)
Mutual labels:  tvos, watchos, carthage
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (+150.95%)
Mutual labels:  tvos, watchos, carthage
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+4998.1%)
Mutual labels:  tvos, watchos, carthage
Sdwebimagewebpcoder
A WebP coder plugin for SDWebImage, use libwebp
Stars: ✭ 101 (-51.9%)
Mutual labels:  tvos, watchos, carthage
Ratelimit
Simple utility for only executing code every so often.
Stars: ✭ 918 (+337.14%)
Mutual labels:  tvos, watchos, carthage
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-37.14%)
Mutual labels:  tvos, watchos, carthage
Rome
Carthage cache for S3, Minio, Ceph, Google Storage, Artifactory and many others
Stars: ✭ 724 (+244.76%)
Mutual labels:  tvos, watchos, carthage
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (-24.76%)
Mutual labels:  tvos, watchos, carthage
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+205.24%)
Mutual labels:  tvos, watchos, carthage
Commoncrypto
CommonCrypto Swift module
Stars: ✭ 87 (-58.57%)
Mutual labels:  tvos, watchos, carthage
Xcglogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.
Stars: ✭ 3,710 (+1666.67%)
Mutual labels:  tvos, watchos, carthage
Json
Micro framework for easily parsing JSON in Swift with rich error messages in less than 100 lines of code
Stars: ✭ 395 (+88.1%)
Mutual labels:  tvos, watchos, carthage
Mixpanel
Unofficial Swift Mixpanel client
Stars: ✭ 93 (-55.71%)
Mutual labels:  tvos, watchos, carthage
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-43.33%)
Mutual labels:  tvos, watchos, carthage

Cache

Version Carthage compatible

A generic caching library for Swift. Cache depends on Foundation.

This is still very much a work in progress.

Usage

Cache provides a simple Cache protocol:

protocol Cache {
  associatedtype Element

  func get(key key: String, completion: (Element? -> Void))
  func set(key key: String, value: Element, completion: (() -> Void)?)
  func remove(key key: String, completion: (() -> Void)?)
  func removeAll(completion completion: (() -> Void)?)
}

There are two (well actually three, but we'll get there) provided caches:

  • MemoryCache — Backed by an NSCache
  • DiskCache — Backed by files on disk using NSFileManager

Using both of these is exactly the same interface.

MultiCache

There is a third cache provided called MultiCache. This combines caches.

let cache = MultiCache(caches: [memoryCache, diskCache])
cache.set(key: "foo", value: "bar")

This will write to all caches in parallel. When accessing the multi cache, it will go in order. In this example, it will try the memory cache and if there's a miss it will try the disk cache. If it were to find it in the disk cache, it will write it to all previous caches for faster future reads.

Thanks

Thanks to Caleb Davenport for unintentionally inspiring this and lots of help along the way.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].