MemoryStorage class
A simple in-memory storage provider for development and testing.
This class implements the legacy Storage contract. Use MemoryStorageV2 for the structured StorageV2 contract.
- Extends
-
MemoryStorageInternals
Constructors
| Memory |
Inherited Properties
| state |
Methods
| delete(string[]) | Deletes legacy items from process-local memory. |
| get |
|
| read(string[]) | Reads legacy items from process-local memory. |
| write(Store |
Writes legacy items to process-local memory. |
Inherited Methods
| get |
|
| is |
|
| remove(string) | |
| save(string, unknown, number) |
Constructor Details
MemoryStorage({[key: string]: string})
new MemoryStorage(memory?: {[key: string]: string})
Parameters
- memory
-
{[key: string]: string}
Inherited Property Details
state
state: MemoryStorageState
Property Value
MemoryStorageState
Inherited From MemoryStorageInternals.state
Method Details
delete(string[])
Deletes legacy items from process-local memory.
function delete(keys: string[]): Promise<void>
Parameters
- keys
-
string[]
The keys to delete. Missing keys are ignored.
Returns
Promise<void>
getSingleInstance()
read(string[])
Reads legacy items from process-local memory.
function read(keys: string[]): Promise<StoreItem>
Parameters
- keys
-
string[]
The keys to read; must not be empty.
Returns
Promise<StoreItem>
Existing items keyed by storage key. Missing keys are omitted and returned items
include their legacy eTag.
write(StoreItem)
Writes legacy items to process-local memory.
function write(changes: StoreItem): Promise<void>
Parameters
- changes
- StoreItem
The items to write, keyed by storage key.
Returns
Promise<void>
Inherited Method Details
getVersion(string, StoreItem)
function getVersion(key: string, value: StoreItem): string | undefined
Parameters
- key
-
string
- value
- StoreItem
Returns
string | undefined
Inherited From MemoryStorageInternals.getVersion
isExpired(string)
function isExpired(key: string): boolean
Parameters
- key
-
string
Returns
boolean
Inherited From MemoryStorageInternals.isExpired
remove(string)
function remove(key: string)
Parameters
- key
-
string
Inherited From MemoryStorageInternals.remove
save(string, unknown, number)
function save(key: string, item: unknown, expiresAt?: number): string
Parameters
- key
-
string
- item
-
unknown
- expiresAt
-
number
Returns
string
Inherited From MemoryStorageInternals.save