Use the API to retrieve the entry key, entry value, and the RegionEntry object itself. A variety of functions provide information for individual entries and for the set of all entries resident in the region. The online API documentation lists all available access functions.
A region's entry keys and RegionEntry objects are directly available from the local cache. Applications can directly access the local cache's stored entry value through the RegionEntry::getValue function. The getValue function either returns the value if a valid value is present in the local cache, or NULL if the value is not valid locally. This function does no data loading, nor does it look elsewhere in the distributed system for a valid value.
In comparison, the standard Region::get functions consider all caches and all applicable loaders in the distributed system in an attempt to return a valid entry value to the calling application. The primary attribute setting affecting entry retrieval is CacheLoader. See Specifying Application Plug-In Attributes.
The standard Region::get functions may implement a number of operations in order to retrieve a valid entry value. The operations used depend on the region's attribute settings and on the state of the entry itself. By default, the client retrieves entry values through calls to the get function. The client can override this behavior for any region by defining a cache loader for the region.
The following sections discuss the get function and special considerations for entry retrieval.
You retrieve entry values with the Region::get function.
When an entry value is requested from a region, it is either retrieved from the cache server or fetched by the region's locally-defined cache loader in this sequence:
- local cache search
- server cache
- local load (For distributed regions, the local load is fetched before remote cache values)
How the get Operation Affects the Local Entry Value
If a get operation retrieves an entry value from outside the local cache through a local load, it automatically puts the value into the cache for future reference.
Note that these load operations do not invoke a cache writer. Because the loader and writer operate against the same data source, you do not need to perform a cache write for entries that were just fetched from that data source. For descriptions of these processes, see Specifying Application Plug-In Attributes.
Getting Multiple Entries Using getAll
You can use the getAll Region API to get all values for an array of keys from the local cache or cache server. Under Bulk Put Operations Using putAll for more information.