InMemoryDocumentStorage

In-memory implementation of DidDocumentStorage.

Uses a Mutex to keep document and metadata changes atomic. Documents are stored in memory and will be lost on application restart.

Use Cases:

  • Testing and development

  • Single-instance deployments where persistence is not required

  • Short-lived operations that don't need to survive restarts

  • Caching layer for other storage backends

Limitations:

  • Not persistent across restarts

  • Limited by available memory

  • No distributed access (single instance only)

Example Usage:

val storage = InMemoryDocumentStorage()

storage.store(
did = Did("did:key:z6Mk..."),
document = didDocument,
metadata = DidDocumentMetadata(created = Clock.System.now())
)

val (document, metadata) = storage.get(Did("did:key:z6Mk..."))

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val backend: StorageBackend

The storage backend type identifier.

Functions

Link copied to clipboard
suspend fun clear()

Clears all documents and their metadata.

Link copied to clipboard
open suspend override fun deactivate(did: Did, deactivatedDocument: DidDocument)

Marks a DID document as deactivated.

Link copied to clipboard
open suspend override fun delete(did: Did): Boolean

Deletes a DID document (for cleanup).

Link copied to clipboard
open suspend override fun exists(did: Did): Boolean

Checks if a DID document exists.

Link copied to clipboard
open suspend override fun get(did: Did): Pair<DidDocument, DidDocumentMetadata>?

Retrieves a DID document by DID.

Link copied to clipboard
suspend fun size(): Int

Returns the number of stored documents.

Link copied to clipboard
open suspend override fun store(did: Did, document: DidDocument, metadata: DidDocumentMetadata? = null)

Stores a DID document.

Link copied to clipboard
open suspend override fun update(did: Did, updater: (DidDocument) -> DidDocument): DidDocument

Updates an existing DID document.