OZInMemoryStorageAdapter
public final actor OZInMemoryStorageAdapter : OZStorageAdapter
extension OZInMemoryStorageAdapter: Equatable
extension OZInMemoryStorageAdapter: Hashable
In-memory storage adapter for credentials and sessions.
Stores all data in memory and does not persist across application restarts. Thread-safe via Swift Concurrency actor isolation.
Use OZKeychainStorageAdapter for persistent encrypted storage on Apple platforms
(Keychain Services), or OZUserDefaultsStorageAdapter for non-sensitive metadata.
All OZInMemoryStorageAdapter instances are considered equal because two
freshly-created instances are functionally identical (both empty), so they are
interchangeable as default values in configuration data structures.
Example:
let storage = OZInMemoryStorageAdapter()
let credential = OZStoredCredential(...)
try await storage.save(credential: credential)
Important
Not persistent and not secure. Data is held in process memory only, is lost on application termination, and is not encrypted at rest. Suitable for tests and ephemeral demos. Production applications must supply a persistent, encrypted storage adapter (for example a Keychain-backed implementation on Apple platforms).-
Initializes a new empty in-memory storage adapter.
Declaration
Swift
public init() -
save(credential:Asynchronous) Declaration
Swift
public func save(credential: OZStoredCredential) async throws -
get(credentialId:Asynchronous) Declaration
Swift
public func get(credentialId: String) async throws -> OZStoredCredential? -
getByContract(contractId:Asynchronous) Declaration
Swift
public func getByContract(contractId: String) async throws -> [OZStoredCredential] -
getAll()AsynchronousDeclaration
Swift
public func getAll() async throws -> [OZStoredCredential] -
delete(credentialId:Asynchronous) Declaration
Swift
public func delete(credentialId: String) async throws -
update(credentialId:Asynchronousupdates: ) Declaration
Swift
public func update(credentialId: String, updates: OZStoredCredentialUpdate) async throws -
clear()AsynchronousDeclaration
Swift
public func clear() async throws -
saveSession(_:Asynchronous) Declaration
Swift
public func saveSession(_ session: OZStoredSession) async throws -
getSession()AsynchronousDeclaration
Swift
public func getSession() async throws -> OZStoredSession? -
clearSession()AsynchronousDeclaration
Swift
public func clearSession() async throws -
All
OZInMemoryStorageAdapterinstances compare equal.Two freshly-constructed instances are functionally indistinguishable (both empty), and this equivalence is what makes structural equality on configuration types behave intuitively when the default in-memory adapter is used in two configurations that are otherwise equal.
Declaration
Swift
public nonisolated static func == (lhs: OZInMemoryStorageAdapter, rhs: OZInMemoryStorageAdapter) -> Bool -
Declaration
Swift
public nonisolated func hash(into hasher: inout Hasher)
View on GitHub
Install in Dash