Cache Loaders
Loaders provide an optional mechanism for loading data into the cache from a backend datastore, such as a relational database. Users can implement and associate Cache Loaders with a region of the cache. These Cache Loaders can be installed locally on the client (Driver or Engine) or globally, in the GridServer Broker.
Global
Use a Global Cache Loader for synchronized regions from which all clients can access data.
-
Global loaders are defined and configured in the schemas.
-
When other clients get access to that region, they automatically are using that loader.
-
A client can specifically pre-load data into the cache by explicitly calling the load method with a single key or a list of keys.
-
If a get does not find data, the loader then attempts to load for that key by calling the loader’s load method.
-
Puts are not allowed on regions with loaders.
-
Global loaders are written in Java, but can be bridged to native or .NET code through JNI.
-
Global CacheLoader JAR files are deployed to the
libdirectory in the cache directory. By default, the cache directory isDS_DATA/cache. Configure the cache directory in the Cache section of the Manager Configuration page in the Administration Tool.
Local
Use a local loader to cache data locally from an external database. Clients do not share local loaders.
-
Puts (writes) are not allowed, as it is a local cache, and data is not propagated to other clients or regions.
-
Removing an item is not allowed. Instead, invalidate the item. Invalidating causes the item to be removed from other client’s caches.
-
Local loaders can only be .NET or Java. You can adapt CPP loaders through JNI or managed C++.