Protocolhummingbird 2.15.0Hummingbird
PersistDriver
Protocol for driver supporting persistent Key/Value pairs across requests
protocol PersistDriver : ServiceBrowse conforming typesProtocol for driver supporting persistent Key/Value pairs across requests
protocol PersistDriver : Serviceimport Hummingbirdprotocol SendableA thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races. Values of the type may have no shared mutable state, or they may protect that state with a lock or by forcing it to only be accessed from a specific actor.
func create<Object>(key: String, value: Object, expires: Duration?) async throws where Object : Decodable, Object : Encodable, Object : Sendable create key/value pair. If key already exist throw PersistError.duplicate error
func get<Object>(key: String, as: Object.Type) async throws -> Object? where Object : Decodable, Object : Encodable, Object : Sendable get value for key
func remove(key: String) async throws remove value associated with key
func set<Object>(key: String, value: Object, expires: Duration?) async throws where Object : Decodable, Object : Encodable, Object : Sendable set value for key. If value already exists overwrite it
func shutdown() async throws shutdown driver
func create(key: String, value: some Decodable & Encodable & Sendable) async throws create key/value pair. If key already exist throw PersistError.duplicate error
func run() async throws func set(key: String, value: some Decodable & Encodable & Sendable) async throws set value for key. If value already exists overwrite it
func shutdown() async throws default implemenation of shutdown()