Перейти к содержанию

CLASS

MemoryStorageDriver

open class MemoryStorageDriver: StorageDriver

A simple in-memory key-value storage for client apps

Methods

init()

public init()

write(meta:data:)

public func write(meta: StorageMeta, data: StorageData) async

Write a unit of data into storage, uniquely identified by meta

If such unit of data already exists, it is silently overwritten

Parameters

Name Description
meta StorageMeta composite identifier
data StorageData unit of data to insert

Returns

void

read(meta:)

public func read(meta: StorageMeta) async -> StorageData?

Read data stored under the provided meta

This method is typically used in a permanent storage strategy

Parameters

Name Description
meta StorageMeta composite identifier

Returns

StorageData

stored data, or null if not found

take(meta:)

public func take(meta: StorageMeta) async -> StorageData?

Take the data stored under the provided meta and remove original

This method is typically used in a temporary storage strategy and as a mean to delete stored entry

Parameters

Name Description
meta StorageMeta composite identifier

Returns

StorageData

stored data, or null if not found