CacheIsKing alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view CacheIsKing alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
A handy collection of more than 500 native Swift extensions to boost your productivity. -
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects -
SwiftGen
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
SwiftGen-Storyboard
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
Dollar
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript -
swift-protobuf
Plugin and runtime library for using protobuf with Swift -
EZSwiftExtensions
:smirk: How Swift standard types and classes were supposed to work. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
Result
Swift type modelling the success/failure of arbitrary operations. -
DeepDiff
🦀Amazingly incredible extraordinary lightning fast diffing in Swift -
Device
Light weight tool for detecting the current device and screen size written in swift. -
SwiftLinkPreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
Codextended
Extensions giving Swift's Codable API type inference super powers 🦸♂️🦹♀️ -
Popsicle
Delightful, extensible Swift value interpolation framework. -
SwiftyJSONAccelerator
macOS app to generate Swift 5 code for models from JSON (with Codeable) -
Playbook
📘A library for isolated developing UI components and automatically taking snapshots of them. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
ObjectiveKit
Swift-friendly API for a set of powerful Objective C runtime functions. -
Compass
:earth_africa: Compass helps you setup a central navigation system for your application -
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift -
Solar
A Swift micro library for generating Sunrise and Sunset times. -
Pythonic.swift
Pythonic tool-belt for Swift – a Swift implementation of selected parts of Python standard library. -
SwiftyUtils
All the reusable code that we need in each project -
Prototope
Swift library of lightweight interfaces for prototyping, bridged to JS.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of CacheIsKing or a related project?
README
CacheIsKing
CacheIsKing
is a simple cache that allows you to store any item, including objects, pure Swift structs, enums (with associated values), etc. Simply put, it's designed to act like an NSCache
for everything, including Swift variables.
Features
- Simply set, get, and remove items based on any key that is
Hashable
- Remove items for any key that matches a filter
- The cache is cleared when the app receives a memory warning
- Similar to
NSCache
, the cache is cleared when the app enters the background - Subscripts are supported for
String
,Int
, andFloat
keys item(for:)
uses generics so you don't have to cast the return value when the type is inferred correctly- Similar to
NSCache
, the cache can have acountLimit
set to ensure that the cache doesn't get too large
Requirements
- iOS 8.0+
- tvOS 9.0+
- Xcode 7+
Installation using CocoaPods
CocoaPods is a dependency manager for Cocoa projects.
Because CacheIsKing
is written in Swift, you must use frameworks.
To integrate CacheIsKing
into your Xcode project using CocoaPods, specify it in your Podfile
:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'CacheIsKing'
Then, run the following command:
$ pod install
Installation using Carthage
Add this to your Cartfile
:
github "nuudles/CacheIsKing"
Usage
Simply use the KingCache
class similar to how you'd use a NSCache
. Using the setItem
and itemForKey
methods allow you to use type inference to get the values you want.
let cache = KingCache()
cache.set(item: 123, for: "123")
if let item: Int = cache.item(for: 456) {
doSomethingWithItem(item)
}
You can also use subscripts to set/get items from the cache. Unfortunately since Swift doesn't support subscript methods with generics yet, you'll have to cast your items as necessary. Also currently only String
, Int
, and Float
keys are supported:
let cache = KingCache()
cache["123"] = 123
if let item = cache[456] as? Int {
doSomethingWithItem(item)
}
The KingCache
also has a countLimit
property, which allows you to set the maximum number of items in the cache. It currently evicts randomly until the countLimit
is met.
let cache = KingCache()
cache.countLimit = 2
cache[123] = 123
cache[234] = 234
cache[345] = 345
print("\(cache.count)") // shows a count of 2
TODO
- Refine eviction algorithm (currently evicts randomly)
- Update with better subscript support once Swift supports subscripts with generics