Class: PackerCache

PackerCache

new PackerCache()

The packer cache service enables packing strategies to register raw object data that can be then used by supporting relations during the decoding process to preload other related resources.

This is specially useful for apis that include linked objects data in external metadata.

The packer cache is reset on every response unwrapping so it's not supposed to be used as an application wide cache.

For extension developers:

Use the feed method to add new raw data to cache.

For relation developers:

Use the resolve method to inject cache data into a given identified record.

Source:
  • module/packer-cache.js, line 7

Methods

feed(_name, _rawRecords)

Feed data to the cache.

Parameters:
Name Type Description
_name string

Resource name (singular)

_rawRecords array

Raw record data as an array

Source:
  • module/packer-cache.js, line 38

resolve(_record) → {RecordApi}

Searches for data matching the record's pk, if found data is then fed to the record using $decode.

Parameters:
Name Type Description
_record RecordApi

restmod record to resolve, must be identified.

Source:
  • module/packer-cache.js, line 52
Returns:

The record, so call can be nested.

Type
RecordApi