Caching the value of computable attribute

Description

When applying the cached values, the attribute values are calculated during creating and editing an object. Previously calculated values are used for the samples.

If there are two computable attributes A and B referring to the collection C and the A has the cached value and B hasn’t, then when editing the object, the collection C will be pulled twice. First time for the attribute B at the securedDataRepo level to verify the access. Second time for the attribute A when calculated into the dataRepo. In this case, when reading an object from the database, the cache of the attribute A simply does not make sense, since in any case the collection will be selected for the attribute B.

Caching semantics

Set the following property to cache semantics of the objects in meta class:

semanticCached: true

We recommend you not to use the eager loading for the attributes used in the cached semantics. Also, we recommend you not to use the dates, because they cannot be converted to the user’s time zone, since they are cached when editing an object at the DBAL level.

Caching the value of computable attribute

Set the following property in the meta class to cache the value of the computable attribute:

cached: true

Besides, you can update caches of objects by reference when editing the main object.

Set the following property in the meta class:

cacheDependencies: ["refAttr1", "refAttr2.refAttr3", "refAttr2.collAttr4"]

When configuring the meta class, specify the reference and collections, the caches of the objects in which you need to update when editing an object of this class. Updates are done recursively. If the refAttr1 attribute is set to update caches in the class object, then the update will start. This setting is inherited in the heir classes.

Example:

{
      "orderNumber": 40,
      "name": "kolStatOps",
      "caption": "Количество стационарных ОПС",
      "type": 6,
      "size": null,
      "decimals": 0,
      "allowedFileTypes": null,
      "maxFileCount": 0,
      "nullable": true,
      "readonly": false,
      "indexed": true,
      "unique": false,
      "autoassigned": false,
      "hint": null,
      "defaultValue": null,
      "refClass": "",
      "itemsClass": "",
      "backRef": "",
      "backColl": "",
      "binding": "",
      "semantic": null,
      "selConditions": [],
      "selSorting": [],
      "selectionProvider": null,
      "indexSearch": false,
      "eagerLoading": false,
      "formula": "count($raionObslu.oktmo_nasPunkta.svyaz.ops,&eq($gops, b), 1)",
      "cached": true
 }

The value of this attribute obtained from the formula is cached. Additionally, to update the value when editing an object, you need to update the caches of objects by reference: to do this, specify cacheDependencies: in the meta class of each object by reference.

Example:

{
  "isStruct": false,
  "key": [
    "okato"
  ],
  "semantic": "name",
  "name": "naselenniyPunkt",
  "version": "",
  "caption": "Населенный пункт",
  "ancestor": null,
  "container": "",
  "creationTracker": "",
  "changeTracker": "",
  "history": 0,
  "journaling": true,
  "compositeIndexes": null,
  "cacheDependencies": ["supOktmo"],
  "properties": [
...