Adding Entries to the Cache
A region is populated with cached entries in several ways:
- Explicitly, when an application executes a
putoperation for a single entry or for multiple entries that do not already exist in the cache.
- Implicitly, when a client does a get on a single entry or on multiple entries that do not already exist in the cache. In this case, the entry is retrieved from a remote cache or through a cache loader.
Read about cache loaders at Overview of Application Plug-Ins.
A client can also use
getAllto populate a region with all values for an array of keys. See Accessing Entries.
- Automatically, when entries are created in remote caches.
If any cache writer is available in the distributed region, it is called before the entry is created and it can abort the creation process.
Adding Entries to the Local Cache
If just the local cache is to be populated, you can either
create an entry using the
localCreate Region API, or
put an entry using
DateTime objects must be stored in the cache in UTC, so that times correspond between client and server. If you use a date with a different time zone, convert it when storing into and retrieving from the cache. This example converts a local time to UTC for a put operation:
DateTime t1( 2009, 8, 13, 4, 11, 0, DateTimeKind.Local); region0.Put( 1, t1.ToUniversalTime() );
Adding Multiple Entries Using PutAll
If you need to add many cache entries to a region at one time, you can improve cache performance by using the
putAll function to add them in a single distributed operation. Multiple key/value pairs are stored in a hashmap, then the hashmap contents are processed on the server as either new entries, updates, or invalidates for existing entries.
Under Adding an Entry to the Cache see the subsection titled Bulk Put Operations Using putAll for more information about the