Chalarangelo/jsiqle

Caching mechanism

Chalarangelo opened this issue · 3 comments

Add a caching mechanism to records as follows:

  • Expose a readonly Map type named propertyCache.
  • Allow for clear() calls on the propertyCache or expose a clearPropertyCache() method.
  • Specify on the model which properties are cached (e.g via cachedProperties - array of property names).
  • Invalidate cache completely whenever any field on the model changes.
  • Disallow (if possible) property caching for relationship reverses.

Partially implemented in v1.3.0 by providing a cacheProperties on the model and invalidating caches on field changes. Relationship property caching is not allowed.

Future iterations should introduce a clear method for both records and full models.

The readonly propertyCache Map has been implemented as an internal detail for the RecordHandler.

WeakMaps could also be leveraged for this.

Depending on #27, we might change this mechanism to an internal and handle it ourselves.