API Docs for: 5.4.0-alpha.29+64fa97fc
Show:

IdentifierCache Class

Each 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.

Methods

__configureMerge

() private

Internal hook to allow management of merge conflicts with identifiers.

we allow late binding of this private internal merge so that the cache can insert itself here to handle elimination of duplicates

_getRecordIdentifier

() private

_mergeRecordIdentifiers

() private

createIdentifierForNewRecord

(
  • data
)
StableRecordIdentifier public

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').

Parameters:

  • data Object

forgetRecordIdentifier

(
  • identifierObject
)
public

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.

Parameters:

  • identifierObject Object

getOrCreateDocumentIdentifier

(
  • request
)
StableDocumentIdentifier | null public

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.

Parameters:

  • request Object

Returns:

StableDocumentIdentifier | null:

getOrCreateRecordIdentifier

(
  • resource
)
StableRecordIdentifier public

Returns the Identifier for the given Resource, creates one if it does not yet exist.

Specifically this means that we:

  • validate the id type and lid combo against known identifiers
  • return an object with an lid that is stable (repeated calls with the same id + type or lid will return the same lid value)
  • this referential stability of the object itself is guaranteed

Parameters:

  • resource Object

peekRecordIdentifier

(
  • resource
)
StableRecordIdentifier | undefined private

allows us to peek without generating when needed useful for the "create" case when we need to see if we are accidentally overwritting something

Parameters:

  • resource Object

Returns:

StableRecordIdentifier | undefined:

updateRecordIdentifier

(
  • identifierObject
  • data
)
StableRecordIdentifier public

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 (if id was previously null)
  • lid and type MUST NOT be altered post creation

If 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.

Parameters:

  • identifierObject Object
  • data Object