MemoryStore
Last updated
Last updated
• Docs
/ / MemoryStore
A store that keeps twines in memory
This store is the base for the .
new MemoryStore(
maxSize
):
Create a new memory store
Parameters
maxSize
number
0
The maximum number of twines to keep in memory (default infinite)
Returns
Defined in
chainStore
protected
Chains are stored in a map with the CID as the key
chainStorageMeta
protected
Chain storage metadata
pulseStore
protected
Pulses are stored in a map with the CID as the key
maxSize
protected
number
The maximum number of twines to keep in memory
setMaxSize(
maxSize
):void
Set the maximum number of twines to keep in memory
If the store is already larger than the new max size, the oldest twines will be removed.
Parameters
maxSize
number
Returns
void
Defined in
Fetch a twine from storage, returning null if it is not found
Parameters
cid
The CID of the twine to fetch
Returns
Implementation of
Defined in
has(
cid
):boolean
Check if a cid can be resolved
Parameters
cid
The CID to check
Returns
boolean
True if the CID can be resolved, false otherwise
Implementation of
Defined in
delete(
cid
):void
Delete a twine from storage
Parameters
cid
The CID of the twine to delete
Returns
void
Implementation of
Defined in
save(
twine
):void
Save a twine to storage
Parameters
twine
The twine to save
Returns
void
Implementation of
Defined in
Save many twines to storage
saveMany(twines)
saveMany(
twines
):Promise
<void
>
Save many twines to storage
Parameters
twines
The twines to save
Returns
Promise
<void
>
Implementation of
Defined in
saveMany(twines)
saveMany(
twines
):void
Save many twines to storage
Parameters
twines
Returns
void
Implementation of
Store.saveMany
Defined in
Get an iterator of all the chains in the store
Returns
Implementation of
Defined in
Get an async iterator of all the pulses in a chain
Parameters
chainCid
start
?
options
?
Returns
Implementation of
Defined in
Resolve a chain from a query
This is the main way to get a pulse or chain from somewhere and have it automatically verified.
If the input is already a successful resolution, it will be returned as is.
If the input is a chain or pulse, it will be resolved as a chain or pulse resolution.
resolve(query, options)
Resolve a chain from a query
This is the main way to get a pulse or chain from somewhere and have it automatically verified.
If the input is already a successful resolution, it will be returned as is.
If the input is a chain or pulse, it will be resolved as a chain or pulse resolution.
Parameters
query
The query to resolve
options
?
Options for the resolution
Returns
A chain or pulse resolution
A chain or pulse resolution
Examples
Implementation of
Defined in
resolve(query, options)
Resolve a pulse (with its chain) from a query
Parameters
query
options
?
Returns
A chain or pulse resolution
Implementation of
Defined in
Resolve the latest pulse of a chain
Parameters
chainCid
The chain CID or chain itself to resolve the latest pulse from
options
?
Options for the resolution
Returns
A pulse resolution
Implementation of
Defined in
Resolve a pulse by index
Parameters
chain
The chain CID or chain itself to resolve the pulse from
index
number
The index of the pulse to resolve
options
?
Options for the resolution
Returns
A pulse resolution
Implementation of
Defined in
Map
<string
, >
Map
<string
, >
<string
, >
fetch(cid
): null
| |
it is NOT expected that the twine signature is checked, that is for the to do.
null
| |
.
.
.
<any
>
.
AsyncIterable
<<>, any
, any
>
.
Iterable
<<>, any
, any
>
chains(): MapIterator
<>
MapIterator
<>
.
pulses(chainCid
, start
?, options
?): AsyncGenerator
<, any
, any
>
number
|
AsyncGenerator
<, any
, any
>
.
resolve(query
, options
?): Promise
<>
Promise
<>
.
resolve(query
, options
?): Promise
<>
Promise
<>
.
resolveLatest(chainCid
, options
?): Promise
<>
Promise
<>
.
resolveIndex(chain
, index
, options
?): Promise
<>
Promise
<>
.