ComposedStorage stores data to multiple storage backends.
- Source:
Examples
Store to LRU and Level
await ComposedStorage(await LRUStorage(), await LevelStorage())
Store to memory and IPFS
await ComposedStorage(await MemoryStorage(), await IPFSBlockStorage())
Store to LRU and a nested ComposedStorage
const storage1 = await ComposedStorage(await LRUStorage(), await LevelStorage())
await ComposedStorage(storage1, await IPFSBlockStorage())
Methods
(async) clear()
Calls clear on each of the composed storages.
- Source:
(async) close()
Calls close on each of the composed storages.
- Source:
(async) del(hash)
Deletes a value from storage.
Parameters:
Name | Type | Description |
---|---|---|
hash |
string | The hash of the value to delete. |
- Source:
(async) get(hash)
Gets data from the composed storage.
Get will fetch the data from storage1 first. If no value is found, an attempt is made to fetch the data from storage2. If data exists in storage2 but not in storage1, the data is added to storage1.
Parameters:
Name | Type | Description |
---|---|---|
hash |
string | The hash of the data to get. |
- Source:
(async, generator) iterator()
Iterates over records stored in both storages.
- Source:
Yields:
(async) merge(other)
Merges data from another source into each of the composed storages.
Parameters:
Name | Type | Description |
---|---|---|
other |
module:Storage | Another storage instance. |
- Source:
(async) put(hash, data)
Puts data to all configured storages.
Parameters:
Name | Type | Description |
---|---|---|
hash |
string | The hash of the data to put. |
data |
* | The data to store. |
- Source: