Using The GridCache API
Details about the GridCache API are in the GridServer API JavaDoc, which is available from the Documentation page of the Administration tool. Documentation for the Cache interface covers the use of GridCache.
The GridCache API supports the following seven primitives:
GridCache constructor with CacheFactory
To create a new GridCache instance, use the CacheFactory to get a reference to a particular region. On a particular client component, you can construct multiple instances of a GridCache with the same region, but each exposed instance with the same region shares the same underlying implementation. This lets multiple Sessions share the same view of a cache without having to duplicate the storage or the code.
Put and Get
The put method writes to the cache a new entry for a key and object. The get method returns the object stored in the cache, for a given key. If you use the get method on a key that does not exist and the region has an associated loader, the loader attempts to load the data for that key. A second get method, when given a mapping of keys, bulk-gets a mapping of keys and their objects. Bulk get methods use a single HTTP request for each map, which can lower transaction overhead.
Region
Region names are any printable low ASCII character (32-126), except for characters prohibited in XML attribute values (', ", &, <).
Keys
A Key is a string that refers to an object in the cache. The keys method gets:
| • | For a global region type, a list of all keys currently stored on the Manager for this cache. |
| • | For a local region type, a list of locally cached keys. |
Remove
Removes this object from the region, from the Manager, and from all distributed caches.
Clear
Clears all objects from the region, the Manager, and regions on other components.
Invalidation handlers
By default, GridCache implements a lazy invalidation mechanism where callers are told only that their version of an object is out-of-date when they make a fresh “get” call for the object. The invalidation handler interface lets the caller register or deregister to receive asynchronous notification that a get, put, remove, or clear has invalidated the caller’s local copy of an object.
Note that .NET cache loaders for GridCache must be packaged as a Super Grid Library. For more information about using Super Grid Libraries, see the TIBCO GridServer® Administration.