Class IdentifierCache

public

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.

Show:

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

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.

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