ComposedStorage stores data to multiple storage backends.
- Source:
Examples
await ComposedStorage(await LRUStorage(), await LevelStorage())
await ComposedStorage(await MemoryStorage(), await IPFSBlockStorage())
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:
[string, string] The next key/value pair from all storages.
(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: