org.eso.ias.utils.pcache
Members list
Packages
Type members
Classlikes
The interface for the in-memory cache
The interface for the in-memory cache
This interface is te same as NonVolatileCache: we keep both as they might diverge in future and reduce teh chance of errors instantiating the higher level cache
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class InMemoryCacheImpl
The trait for the cache of objects persisted in non-volatile memory
The trait for the cache of objects persisted in non-volatile memory
This interface is te same as InMemoryCache: we keep both as they might diverge in future and reduce teh chance of errors instantiating the higher level cache
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
PCache is a cache that optionally persists objects in a DB or a file or other means (depending on the implementation).
PCache is a cache that optionally persists objects in a DB or a file or other means (depending on the implementation).
Objects implementing this class store in memory up to n objects or up to the size of the objects in memory passes a given threshold; when the in-memory cache is filled, new objects are persisted.
Giving a max number of objects (or memory used by them) equals to 0 force all objects to be persisted. The first threshold that is passed )(num. of items or memory consumption) triggers the storage of new item in the non-volatile cache.
The way objects are persisted depends on the implementation, it can be on file or a RDBMS or other means) and it is transparent to the users.
Each object persisted in PCache is identified by a key (pretty much like a Map). In the scope of the IAS, it makes sense to store in the cache JSON strings as almost everything can be translated to/from JSON strings and has an ID (IASIOs, CONVERTERS...).
The memory used by the objects in the map consists on the sum of the sizes of the keys plus the sizes of the JSON strings i.e. PCache does not take into account the memory used to store the objects (for example if the objects are stored in a Map, the memory does not consider the memory used by the Map itself). There are more accurate solutions but we do not want to instrument the code or add complexity when not strictly necessary.
Besides the key and the JSON string, what PCache ultimately stores depends on the memory and persistence implementations.
There are many caches available on the open source world but actually in the IAS the need for a cache is to store objects in memory avoiding the risk of OoM. The objects will be put in cache and retrieved by their IDs (pretty much a single table of a RDBMS). As such, PCache is basically a Map protected against OoM.
PCache delegates the in-memory cache to implementers of InMemoryCache that can either use scala/java code or delegate to third party open source tools. For persisting objects in non-volatile memory, (implementers of NonVolatileCache), PCache delegates to open source tools. Implementers of InMemoryCache can rely on external services (elasticsearch, redis...) especially if such services are already available in the system.
Value parameters
- maxMemSize
-
The max size (MBytes) of memory that can be used by the object in memory
- maxSize
-
The max number of items to keep in memory
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any