Class Store

public

A Store coordinates interaction between your application, a Cache, and sources of data (such as your API or a local persistence layer) accessed via a RequestManager.

app/services/store.js
import Store from '@ember-data/store';

export default class extends Store {}

Most Applications will only have a single Store configured as a Service in this manner. However, setting up multiple stores is possible, including using each as a unique service or within a specific context.

Show:

Returns the cache instance associated to this Store, instantiates the Cache if necessary via Store.createCache

Provides access to the IdentifierCache instance for this store.

The IdentifierCache can be used to generate or retrieve a stable unique identifier for any resource.

A Property which an App may set to provide a CachePolicy to control when a cached request becomes stale.

Note, when defined, these methods will only be invoked if a cache key exists for the request, either because the request contains cacheOptions.key or because the IdentifierCache was able to generate a key for the request using the configured generation method.

isSoftExpired will only be invoked if isHardExpired returns false.

store.lifetimes = {
  // make the request and ignore the current cache state
  isHardExpired(identifier: StableDocumentIdentifier): boolean {
    return false;
  }

  // make the request in the background if true, return cache state
  isSoftExpired(identifier: StableDocumentIdentifier): boolean {
    return false;
  }
}

Provides access to the NotificationManager associated with this Store instance.

The NotificationManager can be used to subscribe to changes to the cache.

Provides access to the requestManager instance associated with this Store instance.

When using ember-data this property is automatically set to an instance of RequestManager. When not using ember-data you must configure this property yourself, either by declaring it as a service or by initializing it.

import Store, { CacheHandler } from '@ember-data/store';
import RequestManager from '@ember-data/request';
import Fetch from '@ember-data/request/fetch';

class extends Store {
  constructor() {
    super(...arguments);
    this.requestManager = new RequestManager();
    this.requestManager.use([Fetch]);
    this.requestManager.useCache(CacheHandler);
  }
}

Provides access to the SchemaService instance for this Store instance.

The SchemaService can be used to query for information about the schema of a resource.