Improve entity caching (multiple IDs, subscriptionless, contents)
This MR adds support for caching of entities which are requested in bulk, caching without individual subscriptions and uses these improvements to enable caching for contents.
Caching is a little more involved when multiple entities are retrieved at once. Some but not all entities might already be cached. In this case, only the missing entities are retrieved while the cached entities are transparently added to the list. The entities are sorted corresponding to the original order of IDs.
Previously, entities could not be cached w/o individual subscription because they would get stale when there are server-side changes to them. Now, the room-wide subscription is used to detect when entities become stale and remove them from the cache if the is no individual subscription which would lead to a cache update.
AbstractEntityService
s useSharedCache
has been renamed to
useChangeSubscriptions
because it is now also used to control the
subscription behavior. Both share the same state because without
individual subscriptions, the shared cache cannot be used.
With the previous caching changes to AbstractEntityService
, contents
can now be cached. Individual change subscriptions are not enabled for
contents because
a) it is likely that the changed entity will no longer be requested
later on and
b) this could lead to a huge amount of subscriptions.
Also, the size of the room-specific cache has been increase to provide space for contents.
A lower limit (30) was previously used, to indirectly limit the number
of subscriptions. Since room-specific caching does not rely on
individual subscriptions, a much higher limit (200) is appropriate.
Furthermore, the previously content-specific partitioning logic was moved to the
AbstractEntityService
. This also adjusts the logic to apply
partitioning AFTER the cached entities have been retrieved, so
partitioning is only applied to the entities which actually need to be
fetched.
Closes: #1141 (closed), #1143 (closed)
Related: #1140