cauli
cauli copied to clipboard
Add functions to store arbitrary data in a Storage
Description
Currently, a Storage can only store records. I would love to be able to store arbitrary data (for example everything that is codable) under a given key.
Usecase
If I want to write a Floret that stores the number if outgoing and incoming bytes per domain to display that as a statistic, I would currently manage the storage by myself. I think it would be great to be able to store such data in the Storage.
Proposal
- Add two new functions to the storage protocol
protocol Storage {
func store<T: Codable>(_ object: T, forKey key: String)
func object<T: Codable>(forKey key: String) -> T?
}
- To be able to store such data, a TrafficCalculatorFloret would have to be initialized with a storage.