home
  • Blog
  • Home
  • Projects
    • Ember
    • EmberData
    • Ember CLI
4.12
  • Packages
    • @ember-data/adapter
    • @ember-data/adapter/error
    • @ember-data/adapter/json-api
    • @ember-data/adapter/rest
    • @ember-data/canary-features
    • @ember-data/debug
    • @ember-data/deprecations
    • @ember-data/experimental-preview-types
    • @ember-data/graph
    • @ember-data/json-api
    • @ember-data/legacy-compat
    • @ember-data/model
    • @ember-data/request
    • @ember-data/request/fetch
    • @ember-data/serializer
    • @ember-data/serializer/json
    • @ember-data/serializer/json-api
    • @ember-data/serializer/rest
    • @ember-data/store
    • @ember-data/tracking
  • Classes
    • <Interface> Adapter
    • <Interface> Cache
    • <Interface> Handler
    • <Interface> Serializer
    • AbortError
    • Adapter
    • AdapterError
    • BelongsToReference
    • BooleanTransform
    • BuildURLMixin
    • Cache
    • CacheManager
    • CacheStoreWrapper
    • CanaryFeatureFlags
    • ConflictError
    • CurrentDeprecations
    • DateTransform
    • DebugLogging
    • EmbeddedRecordsMixin
    • Errors
    • Fetch
    • ForbiddenError
    • Future
    • HasManyReference
    • IdentifierCache
    • InvalidError
    • JSONAPIAdapter
    • JSONAPISerializer
    • JSONSerializer
    • ManyArray
    • Model
    • NotFoundError
    • NotificationManager
    • NumberTransform
    • PromiseArray
    • PromiseManyArray
    • PromiseObject
    • RESTAdapter
    • RESTSerializer
    • RecordArray
    • RecordReference
    • RequestManager
    • RequestStateService
    • SchemaService
    • Serializer
    • ServerError
    • Snapshot
    • SnapshotRecordArray
    • StableRecordIdentifier
    • Store
    • StringTransform
    • TimeoutError
    • Transform
    • UnauthorizedError

Class IdentifierCache public


Defined in: ../store/src/-private/caches/identifier-cache.ts:145
Module: @ember-data/store

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

createIdentifierForNewRecord (data) : StableRecordIdentifier public

Module: @ember-data/store

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

Module: @ember-data/store

Defined in ../packages/store/src/-private/caches/identifier-cache.ts:576

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

Module: @ember-data/store

Defined in ../packages/store/src/-private/caches/identifier-cache.ts:360

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

Module: @ember-data/store

Defined in ../packages/store/src/-private/caches/identifier-cache.ts:394

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

updateRecordIdentifier (identifierObject, data) : StableRecordIdentifier public

Module: @ember-data/store

Defined in ../packages/store/src/-private/caches/identifier-cache.ts:457

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.

On this page


Methods

  • createIdentifierForNewRecord
  • forgetRecordIdentifier
  • getOrCreateDocumentIdentifier
  • getOrCreateRecordIdentifier
  • updateRecordIdentifier
Team Sponsors Security Legal Branding Community Guidelines
Twitter GitHub Discord Mastodon

If you want help you can contact us by email, open an issue, or get realtime help by joining the Ember Discord.

© Copyright 2025 - Tilde Inc.
Ember.js is free, open source and always will be.


Ember is generously supported by
blue Created with Sketch.