Configure AS persistenceto have only a subset of objects in memory (for example based on a timestamp or key).

Configure AS persistenceto have only a subset of objects in memory (for example based on a timestamp or key).

book

Article ID: KB0089346

calendar_today

Updated On:

Products Versions
TIBCO ActiveSpaces -
Not Applicable -

Description

Description:
If we configure AS persistence, would it be possible to have only a subset of objects in memory, for example based on a timestamp or key?
If a client ask AS for data that are not loaded in memory, AS "automagically":
-retieve them from the database.
-load retrieved data in memory.
-return the data union from what in memory with what was loaded from the database.

Issue/Introduction

Configure AS persistenceto have only a subset of objects in memory (for example based on a timestamp or key).

Resolution

SharedAll persistence provides hooks to load data partially, trigger handle misses from the respective backing store in case there is need when you enable capacity on the space.

Users need to implement a persister interface to interact with the database. There is no built-in solution, however under examples we have fully working solutions for PostgreSQL/MySql and it is easily portable to other databases.

Persister interface has a callback onLoad. It is up to user what to load. There are a couple of options:

- Load everything.
- Load subset of the data or do not load anything at all (cold start).

When you load everything the assumption is the data will fit into available memory of the existing seeders. There is no point in setting capacity as anything over the capacity will be evicted. There is no reason to spend time to load the whole dataset.

When you partially load data, you need to enable a mechanism to handle misses in case an operation requires the value. For this you would need to set capacity for the space and set eviction policy to LRU.

Example: Assume you have 10M entries and load 1M according to some criteria. Set capacity to 1M with eviction LRU. Once you issue a get for 2M-th key which is not present in the cache AS will call onRead callback of the persister implementation and the user returns the value if it exists in the database. This value will be loaded into memory to evict some other LRU key if a capacity requirement will be violated.

We don't have a custom eviction policy where you can specify how an eviction should happen.

Additional Information

Refer "SharedAll persistence" from AS developer guide