Skip to main content
Version: 0.17

Class: MemoryCache<QO, TO, QB, TB, QRD, TRD>

A cache used to access records in memory.

Because data is stored in immutable maps, this type of cache can be forked efficiently.

Type parameters

NameType
QOextends RequestOptions = RecordCacheQueryOptions
TOextends RequestOptions = RecordCacheTransformOptions
QBRecordQueryBuilder
TBRecordTransformBuilder
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Hierarchy

  • SyncRecordCache<QO, TO, QB, TB, QRD, TRD>

    MemoryCache

Constructors

constructor

new MemoryCache<QO, TO, QB, TB, QRD, TRD>(settings)

Type parameters

NameType
QOextends RequestOptions = RecordCacheQueryOptions
TOextends RequestOptions = RecordCacheTransformOptions
QBRecordQueryBuilder<string, RecordIdentity>
TBRecordTransformBuilder<string, RecordIdentity, UninitializedRecord>
QRDunknown
TRDextends RecordCacheUpdateDetails = RecordCacheUpdateDetails

Parameters

NameType
settingsMemoryCacheSettings<QO, TO, QB, TB, QRD, TRD>

Overrides

SyncRecordCache<QO, TO, QB, TB, QRD, TRD\>.constructor

Defined in

memory/src/memory-cache.ts:90

Accessors

base

get base(): undefined | MemoryCache<QO, TO, QB, TB, QRD, TRD>

Returns

undefined | MemoryCache<QO, TO, QB, TB, QRD, TRD>

Defined in

memory/src/memory-cache.ts:105


defaultQueryOptions

get defaultQueryOptions(): undefined | DefaultRequestOptions<QueryOptions>

Returns

undefined | DefaultRequestOptions<QueryOptions>

Inherited from

SyncRecordCache.defaultQueryOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:53

set defaultQueryOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<QueryOptions>

Returns

void

Inherited from

SyncRecordCache.defaultQueryOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:54


defaultTransformOptions

get defaultTransformOptions(): undefined | DefaultRequestOptions<TransformOptions>

Returns

undefined | DefaultRequestOptions<TransformOptions>

Inherited from

SyncRecordCache.defaultTransformOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:55

set defaultTransformOptions(options): void

Parameters

NameType
optionsundefined | DefaultRequestOptions<TransformOptions>

Returns

void

Inherited from

SyncRecordCache.defaultTransformOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:56


isTrackingUpdateOperations

get isTrackingUpdateOperations(): boolean

Returns

boolean

Defined in

memory/src/memory-cache.ts:407


keyMap

get keyMap(): undefined | RecordKeyMap

Returns

undefined | RecordKeyMap

Inherited from

SyncRecordCache.keyMap

Defined in

record-cache/dist/modules/record-cache.d.ts:49


name

get name(): undefined | string

Returns

undefined | string

Inherited from

SyncRecordCache.name

Defined in

record-cache/dist/modules/record-cache.d.ts:47


processors

get processors(): SyncOperationProcessor[]

Returns

SyncOperationProcessor[]

Inherited from

SyncRecordCache.processors

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:29


queryBuilder

get queryBuilder(): QueryBuilder

Returns

QueryBuilder

Inherited from

SyncRecordCache.queryBuilder

Defined in

record-cache/dist/modules/record-cache.d.ts:51


schema

get schema(): RecordSchema

Returns

RecordSchema

Inherited from

SyncRecordCache.schema

Defined in

record-cache/dist/modules/record-cache.d.ts:48


transformBuilder

get transformBuilder(): TransformBuilder

Returns

TransformBuilder

Inherited from

SyncRecordCache.transformBuilder

Defined in

record-cache/dist/modules/record-cache.d.ts:52


validatorFor

get validatorFor(): undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Returns

undefined | ValidatorForFn<StandardValidator | StandardRecordValidator>

Inherited from

SyncRecordCache.validatorFor

Defined in

record-cache/dist/modules/record-cache.d.ts:50

Methods

addInverseRelationshipsSync

addInverseRelationshipsSync(relationships): void

Parameters

NameType
relationshipsRecordRelationshipIdentity[]

Returns

void

Overrides

SyncRecordCache.addInverseRelationshipsSync

Defined in

memory/src/memory-cache.ts:317


applyRecordChangesetSync

applyRecordChangesetSync(changeset): void

Parameters

NameType
changesetRecordChangeset

Returns

void

Inherited from

SyncRecordCache.applyRecordChangesetSync

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:42


emit

emit(event, ...args): void

Parameters

NameType
eventEvent
...argsunknown[]

Returns

void

Inherited from

SyncRecordCache.emit

Defined in

core/dist/modules/evented.d.ts:23


fork

fork(settings?): MemoryCache<QO, TO, QB, TB, QRD, TRD>

Create a clone, or "fork", from a "base" cache.

The forked cache will have the same schema and keyMap as its base source. The forked cache will start with the same immutable document as the base source. Its contents and log will evolve independently.

Parameters

NameType
settingsPartial<MemoryCacheSettings<QO, TO, QB, TB, QRD, TRD>>

Returns

MemoryCache<QO, TO, QB, TB, QRD, TRD>

the forked cache

Defined in

memory/src/memory-cache.ts:118


getAllUpdateOperations

getAllUpdateOperations(): RecordOperation[]

Returns

RecordOperation[]

Defined in

memory/src/memory-cache.ts:411


getInverseRelationshipsSync

getInverseRelationshipsSync(recordIdentityOrIdentities): RecordRelationshipIdentity[]

Parameters

NameType
recordIdentityOrIdentitiesRecordIdentity | RecordIdentity[]

Returns

RecordRelationshipIdentity[]

Overrides

SyncRecordCache.getInverseRelationshipsSync

Defined in

memory/src/memory-cache.ts:297


getInverseTransformOperator

getInverseTransformOperator(op): SyncInverseTransformOperator

Parameters

NameType
opstring

Returns

SyncInverseTransformOperator

Inherited from

SyncRecordCache.getInverseTransformOperator

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:32


getQueryOperator

getQueryOperator(op): SyncQueryOperator

Parameters

NameType
opstring

Returns

SyncQueryOperator

Inherited from

SyncRecordCache.getQueryOperator

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:30


getQueryOptions

getQueryOptions(query, expression?): undefined | QO

Parameters

NameType
queryRecordQuery
expression?RecordQueryExpression

Returns

undefined | QO

Inherited from

SyncRecordCache.getQueryOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:57


getRecordSync

getRecordSync(identity): undefined | InitializedRecord

Parameters

NameType
identityRecordIdentity

Returns

undefined | InitializedRecord

Overrides

SyncRecordCache.getRecordSync

Defined in

memory/src/memory-cache.ts:219


getRecordsSync

getRecordsSync(typeOrIdentities?): InitializedRecord[]

Parameters

NameType
typeOrIdentities?string | RecordIdentity[]

Returns

InitializedRecord[]

Overrides

SyncRecordCache.getRecordsSync

Defined in

memory/src/memory-cache.ts:223


getRelatedRecordSync

getRelatedRecordSync(identity, relationship): undefined | null | RecordIdentity

Parameters

NameType
identityRecordIdentity
relationshipstring

Returns

undefined | null | RecordIdentity

Inherited from

SyncRecordCache.getRelatedRecordSync

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:43


getRelatedRecordsSync

getRelatedRecordsSync(identity, relationship): undefined | RecordIdentity[]

Parameters

NameType
identityRecordIdentity
relationshipstring

Returns

undefined | RecordIdentity[]

Inherited from

SyncRecordCache.getRelatedRecordsSync

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:44


getTransformOperator

getTransformOperator(op): SyncTransformOperator

Parameters

NameType
opstring

Returns

SyncTransformOperator

Inherited from

SyncRecordCache.getTransformOperator

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:31


getTransformOptions

getTransformOptions(transform, operation?): undefined | TO

Parameters

NameType
transformRecordTransform
operation?RecordOperation

Returns

undefined | TO

Inherited from

SyncRecordCache.getTransformOptions

Defined in

record-cache/dist/modules/record-cache.d.ts:58


listeners

listeners(event): Listener[]

Parameters

NameType
eventEvent

Returns

Listener[]

Inherited from

SyncRecordCache.listeners

Defined in

core/dist/modules/evented.d.ts:24


liveQuery

liveQuery(queryOrExpressions, options?, id?): SyncLiveQuery<QO, TO, QB, TB>

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns

SyncLiveQuery<QO, TO, QB, TB>

Inherited from

SyncRecordCache.liveQuery

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:61


merge

merge<RequestData>(forkedCache, options?): RequestData

Merges the operations from a forked cache back to this cache.

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
forkedCacheMemoryCache<QO, TO, QB, TB, QRD, TRD>
options?TO & { fullResponse?: false } & MemoryCacheMergeOptions

Returns

RequestData

the result of calling update with the operations

Defined in

memory/src/memory-cache.ts:151

merge<RequestData>(forkedCache, options): FullResponse<RequestData, TRD, RecordOperation>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
forkedCacheMemoryCache<QO, TO, QB, TB, QRD, TRD>
optionsTO & { fullResponse: true } & MemoryCacheMergeOptions

Returns

FullResponse<RequestData, TRD, RecordOperation>

Defined in

memory/src/memory-cache.ts:155


off

off(event, listener?): void

Parameters

NameType
eventEvent
listener?Listener

Returns

void

Inherited from

SyncRecordCache.off

Defined in

core/dist/modules/evented.d.ts:21


on

on(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

SyncRecordCache.on

Defined in

core/dist/modules/evented.d.ts:20


one

one(event, listener): () => void

Parameters

NameType
eventEvent
listenerListener

Returns

fn

▸ (): void

Returns

void

Inherited from

SyncRecordCache.one

Defined in

core/dist/modules/evented.d.ts:22


patch

patch(operationOrOperations): PatchResult

Patches the cache with an operation or operations.

deprecated since v0.17

Parameters

NameType
operationOrOperationsRecordOperation | RecordOperation[] | RecordTransformBuilderFunc | RecordOperationTerm<string, RecordIdentity, UninitializedRecord> | RecordOperationTerm<string, RecordIdentity, UninitializedRecord>[]

Returns

PatchResult

Inherited from

SyncRecordCache.patch

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:60


query

query<RequestData>(queryOrExpressions, options?, id?): RequestData

Queries the cache.

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
options?DefaultRequestOptions<QO>
id?string

Returns

RequestData

Inherited from

SyncRecordCache.query

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:48

query<RequestData>(queryOrExpressions, options, id?): FullResponse<RequestData, QRD, RecordOperation>

Type parameters

NameType
RequestDataextends RecordQueryResult<InitializedRecord> = RecordQueryResult<InitializedRecord>

Parameters

NameType
queryOrExpressionsQueryOrExpressions<RecordQueryExpression, QB>
optionsFullRequestOptions<QO>
id?string

Returns

FullResponse<RequestData, QRD, RecordOperation>

Inherited from

SyncRecordCache.query

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:49


rebase

rebase(): void

Rebase resets this cache's state to that of its base cache, then re-applies any tracked update operations.

Rebasing requires both a base cache as well as tracking of update operations (which is enabled by default when a base cache is assigned).

Returns

void

Defined in

memory/src/memory-cache.ts:196


removeInverseRelationshipsSync

removeInverseRelationshipsSync(relationships): void

Parameters

NameType
relationshipsRecordRelationshipIdentity[]

Returns

void

Overrides

SyncRecordCache.removeInverseRelationshipsSync

Defined in

memory/src/memory-cache.ts:332


removeRecordSync

removeRecordSync(recordIdentity): undefined | InitializedRecord

Parameters

NameType
recordIdentityRecordIdentity

Returns

undefined | InitializedRecord

Overrides

SyncRecordCache.removeRecordSync

Defined in

memory/src/memory-cache.ts:267


removeRecordsSync

removeRecordsSync(recordIdentities): InitializedRecord[]

Parameters

NameType
recordIdentitiesRecordIdentity[]

Returns

InitializedRecord[]

Overrides

SyncRecordCache.removeRecordsSync

Defined in

memory/src/memory-cache.ts:280


reset

reset(): void

Resets the cache's to its initial state, which will be either empty or a clone of its base cache, if it has one.

Returns

void

Defined in

memory/src/memory-cache.ts:359


setRecordSync

setRecordSync(record): void

Parameters

NameType
recordInitializedRecord

Returns

void

Overrides

SyncRecordCache.setRecordSync

Defined in

memory/src/memory-cache.ts:252


setRecordsSync

setRecordsSync(records): void

Parameters

NameType
recordsInitializedRecord[]

Returns

void

Overrides

SyncRecordCache.setRecordsSync

Defined in

memory/src/memory-cache.ts:256


update

update<RequestData>(transformOrOperations, options?, id?): RequestData

Updates the cache.

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
options?DefaultRequestOptions<TO>
id?string

Returns

RequestData

Inherited from

SyncRecordCache.update

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:53

update<RequestData>(transformOrOperations, options, id?): FullResponse<RequestData, TRD, RecordOperation>

Type parameters

NameType
RequestDataextends RecordTransformResult<InitializedRecord> = RecordTransformResult<InitializedRecord>

Parameters

NameType
transformOrOperationsTransformOrOperations<RecordOperation, TB>
optionsFullRequestOptions<TO>
id?string

Returns

FullResponse<RequestData, TRD, RecordOperation>

Inherited from

SyncRecordCache.update

Defined in

record-cache/dist/modules/sync-record-cache.d.ts:54


upgrade

upgrade(): void

Upgrade the cache based on the current state of the schema.

Returns

void

Defined in

memory/src/memory-cache.ts:393