Pivotal GemFire® v8.1

Adding Entries to the Cache

Adding Entries to the Cache

A region is populated with cached entries in several ways:

  • Explicitly, when an application executes a create or a put operation 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 (Under Specifying Application Plug-In Attributessee "CacheLoader"). A client can also use getAll to 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.

Note: For more information on how to create entries, see Pivotal GemFire Native Client C++ API, Pivotal GemFire Native Client C# .NET API, and the native client API reference (

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 localPut. See the C++ and .NET online API documentation for details about localCreate and localPut.

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 "Bulk Put Operations Using putAll" for more information about the putAll API. Additional details are available in the online API documentation for Region::putAll (C++), or Region.PutAll (.NET).