TwineCache
@twine-protocol/twine-core v0.1.0 • Docs
twine-js / @twine-protocol/twine-core / TwineCache
Class: TwineCache
A store that caches twines in memory
Extends
Constructors
new TwineCache()
new TwineCache(
maxSize
):TwineCache
Create a new twine cache
Parameters
maxSize
number
10000
The maximum number of twines to keep in memory (default 10000)
Returns
Overrides
Defined in
packages/twine-core/src/store/memory-store.ts:287
Properties
chainStore
protected
Map
<string
, Chain
>
Chains are stored in a map with the CID as the key
MemoryStore
.chainStore
chainStorageMeta
protected
Map
<string
, ChainStorageMeta
>
Chain storage metadata
MemoryStore
.chainStorageMeta
Methods
get()
Parameters
cid
Returns
Deprecated
Defined in
packages/twine-core/src/store/memory-store.ts:294
add()
add(
twine
):void
Parameters
twine
Twine
<any
>
Returns
void
Deprecated
Defined in
packages/twine-core/src/store/memory-store.ts:303
setMaxSize()
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
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:70
fetch()
Fetch a twine from storage, returning null if it is not found
it is NOT expected that the twine signature is checked, that is for the Resolver to do.
Parameters
Returns
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:81
has()
has(
cid
):boolean
Check if a cid can be resolved
Parameters
Returns
boolean
True if the CID can be resolved, false otherwise
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:97
delete()
delete(
cid
):void
Delete a twine from storage
Parameters
Returns
void
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:105
save()
save(
twine
):void
Save a twine to storage
Parameters
Returns
void
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:147
saveMany()
Save many twines to storage
saveMany(twines)
saveMany(
twines
):Promise
<void
>
Save many twines to storage
Parameters
Returns
Promise
<void
>
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:159
saveMany(twines)
saveMany(
twines
):void
Save many twines to storage
Parameters
twines
Iterable
<Twine
<TwineValue
>, any
, any
>
Returns
void
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:160
chains()
chains():
MapIterator
<Chain
>
Get an iterator of all the chains in the store
Returns
MapIterator
<Chain
>
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:181
pulses()
pulses(
chainCid
,start
?,options
?):AsyncGenerator
<Pulse
,any
,any
>
Get an async iterator of all the pulses in a chain
Parameters
Returns
AsyncGenerator
<Pulse
, any
, any
>
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:188
resolve()
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(
query
,options
?):Promise
<ChainResolution
>
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
Returns
Promise
<ChainResolution
>
A chain or pulse resolution
A chain or pulse resolution
Examples
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:215
resolve(query, options)
resolve(
query
,options
?):Promise
<PulseResolution
>
Resolve a pulse (with its chain) from a query
Parameters
options
?
Returns
Promise
<PulseResolution
>
A chain or pulse resolution
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:216
resolveLatest()
resolveLatest(
chainCid
,options
?):Promise
<PulseResolution
>
Resolve the latest pulse of a chain
Parameters
Returns
Promise
<PulseResolution
>
A pulse resolution
Inherited from
Defined in
packages/twine-core/src/store/memory-store.ts:230
resolveIndex()
resolveIndex(
chain
,index
,options
?):Promise
<PulseResolution
>
Resolve a pulse by index
Parameters
index
number
The index of the pulse to resolve
Returns
Promise
<PulseResolution
>
A pulse resolution
Inherited from
Defined in
Last updated