LATEST VERSION: 9.0.6 - CHANGELOG
Pivotal GemFire® Native Client v9.0

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. Read about cache loaders at Overview of Application Plug-Ins. 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 .NET API, and the native client API reference at http://gemfire-apis.docs.pivotal.io.

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 API documentation at http://gemfire-apis.docs.pivotal.io 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 the subsection titled Bulk Put Operations Using putAll for more information about the putAll API. Additional details are available in the API documentation for Region::putAll (C++), or Region.PutAll (.NET) at http://gemfire-apis.docs.pivotal.io.