0xOpenBytes/Cache
📦 Simple in-memory key-value store
Usage
To use the Cache, first create an instance with the desired key and value types. You can then use the set(:forKey:) method to add items to the cache, and the get(:) method to retrieve items from the cache.
let cache = Cache<String, Int>()
cache.set(42, forKey: "answer")
let answer = cache.get("answer") // answer == 42The Cache also supports removal of items from the cache using the remove(_:) method. To remove all items from the cache, use the clear() method.
let cache = Cache<String, Int>()
cache.set(42, forKey: "answer")
cache.remove("answer")
let answer = cache.get("answer") // answer == nilThread Safety
The Cache is designed to be thread-safe, allowing multiple threads to access and modify the cache without the risk of data races.
Package Metadata
Repository: 0xOpenBytes/Cache
Homepage: https://0xopenbytes.github.io/Cache/
Stars: 3
Forks: 0
Open issues: 0
Default branch: main
Primary language: swift
License: MIT
Topics: cache, data, json, swift
README: README.md