Lightweight Caching Library for Swift. Inspired by Swift By Sundell.
Making an app feel fast and responsive isn’t only about tweaking the way its UI is rendered, or improving the sheer execution speed of its operations and algorithms — it’s often just as much about efficiently managing its data and avoiding unnecessary work.
Many apps do not need an expansive database for managing the data. An efficent implementation that works easily with the Codable protocol is likely more than enough for your average application. The main goal of any software is to create quickly with readability and replaceability. This package is intended to do that, while allowing extensibility if needed.
- 💪 Elegant caching API in Swift
- 🎯 Lightweight and easy to use.
- 🎨 Create Custom Modifiers.
- Implement expiration for
entryLifetime
- add
createdDate
forEntry
- encryption
- Encrypt / decrypt the data object itself: https://stackoverflow.com/a/53246008
- Unit Tests - Full Code Coverage
- Github repo
- Swift Package Support
- add policyTracker
- Policys for how entries are inserted/retrieved
- Cache
status
property (e.g. fresh, expired) - Expiration callback on cache load
- Allow retrieving objects based on predicates
- implement countlimit
- what happens when trying to insert past the count limit
- Create a protocol describing behavior based on caching events
- for example, a callback for expired data or callback for successfully retrieving from cache
- pass in encryption policy or encryption provider
Example 😊
let name = "SwiftStore"
let key = "key"
let store = Cache<String,String>()
store.insert(name, forKey: key)
// Then
let result = store[test.id]
// or
let result = store.value(forKey:key)
Publish is distributed using the Swift Package Manager. To install it into a project, add it as a dependency within your Package.swift
manifest:
let package = Package(
...
dependencies: [
.package(url: "https://github.com/TySchultz/SwiftStore.git", from: "0.1.0")
],
...
)
Then import Publish wherever you’d like to use it:
import SwiftStore
For more information on how to use the Swift Package Manager, check out this article, or its official documentation.