InMemoryStorageAdapter

In-memory storage adapter for credentials and sessions.

This implementation stores all data in memory and does not persist across application restarts. It is thread-safe using mutex protection.

Use platform-specific implementations for persistent storage (e.g., SharedPreferences on Android, UserDefaults on iOS, localStorage on Web).

All InMemoryStorageAdapter instances are considered equal since they are interchangeable when freshly created (both start empty). This enables correct data class equality for configs that use InMemoryStorageAdapter as a default field.

Example:

val storage = InMemoryStorageAdapter()
val credential = StoredCredential(...)
storage.save(credential)

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
open suspend override fun clear()

Clears all credentials from storage.

Link copied to clipboard
open suspend override fun clearSession()

Clears the current session.

Link copied to clipboard
open suspend override fun delete(credentialId: String)

Deletes a credential by its ID.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

All InMemoryStorageAdapter instances are considered equal.

Link copied to clipboard
open suspend override fun get(credentialId: String): StoredCredential?

Retrieves a credential by its ID.

Link copied to clipboard
open suspend override fun getAll(): List<StoredCredential>

Retrieves all stored credentials.

Link copied to clipboard
open suspend override fun getByContract(contractId: String): List<StoredCredential>

Retrieves all credentials associated with a contract address.

Link copied to clipboard
open suspend override fun getSession(): StoredSession?

Retrieves the current session.

Link copied to clipboard
open override fun hashCode(): Int

Consistent hash code for all InMemoryStorageAdapter instances.

Link copied to clipboard
open suspend override fun save(credential: StoredCredential)

Saves a credential to storage using upsert semantics.

Link copied to clipboard
open suspend override fun saveSession(session: StoredSession)

Saves a session to storage.

Link copied to clipboard
open suspend override fun update(credentialId: String, updates: StoredCredentialUpdate)

Updates a credential with partial changes.