Class IdentifierCache
publicEach instance of {Store} receives a unique instance of a IdentifierCache.
This cache is responsible for assigning or retrieving the unique identify for arbitrary resource data encountered by the store. Data representing a unique resource or record should always be represented by the same identifier.
It can be configured by consuming applications.
createIdentifierForNewRecord (data) StableRecordIdentifier public
Defined in ../packages/store/src/-private/caches/identifier-cache.ts:417
- data
- returns
- StableRecordIdentifier
Returns a new Identifier for the supplied data. Call this method to generate
an identifier when a new resource is being created local to the client and
potentially does not have an id
.
Delegates generation to the user supplied GenerateMethod
if one has been provided
with the signature generateMethod({ type }, 'record')
.
forgetRecordIdentifier (identifierObject) public
Defined in ../packages/store/src/-private/caches/identifier-cache.ts:590
- identifierObject
Provides the opportunity to eliminate an identifier from secondary lookup tables as well as eliminates it from ember-data's own lookup tables and book keeping.
Useful when a record has been deleted and the deletion has been persisted and
we do not care about the record anymore. Especially useful when an id
of a
deleted record might be reused later for a new record.
getOrCreateDocumentIdentifier (request) StableDocumentIdentifier | null public
Defined in ../packages/store/src/-private/caches/identifier-cache.ts:364
- request
- returns
- StableDocumentIdentifier | null
Returns the DocumentIdentifier for the given Request, creates one if it does not yet exist.
Returns null
if the request does not have a cacheKey
or url
.
getOrCreateRecordIdentifier (resource) StableRecordIdentifier public
Defined in ../packages/store/src/-private/caches/identifier-cache.ts:398
- resource
- returns
- StableRecordIdentifier
Returns the Identifier for the given Resource, creates one if it does not yet exist.
Specifically this means that we:
- validate the
id
type
andlid
combo against known identifiers - return an object with an
lid
that is stable (repeated calls with the sameid
+type
orlid
will return the samelid
value) - this referential stability of the object itself is guaranteed
updateRecordIdentifier (identifierObject, data) StableRecordIdentifier public
Defined in ../packages/store/src/-private/caches/identifier-cache.ts:455
- identifierObject
- data
- returns
- StableRecordIdentifier
Provides the opportunity to update secondary lookup tables for existing identifiers
Called after an identifier created with createIdentifierForNewRecord
has been
committed.
Assigned id
to an Identifier
if id
has not previously existed; however,
attempting to change the id
or calling update without providing an id
when
one is missing will throw an error.
sets
id
(ifid
was previouslynull
)lid
andtype
MUST NOT be altered post creationIf a merge occurs, it is possible the returned identifier does not match the originally provided identifier. In this case the abandoned identifier will go through the usual
forgetRecordIdentifier
codepaths.