Caching mechanism
Chalarangelo opened this issue · 3 comments
Chalarangelo commented
Add a caching mechanism to records as follows:
- Expose a readonly
Map
type namedpropertyCache
. - Allow for
clear()
calls on thepropertyCache
or expose aclearPropertyCache()
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.
Chalarangelo commented
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
.
Chalarangelo commented
WeakMap
s could also be leveraged for this.
Chalarangelo commented
Depending on #27, we might change this mechanism to an internal and handle it ourselves.