| | {include:OG_HEADER} |
| | {style} |
| | h3 { |
| | color: #0099cc; |
| | } |
| | h4 { |
| | color: #0099cc; |
| | } |
| | h5 { |
| | color: #0099cc; |
| | } |
| | | {style}{excerpt}The ObjectMap API provides a transactional map-based API that allows typical CRUD (Create, Read, Update and Delete) operations to the ObjectGrid cache. Similar, to the java.util.Map interface, it also adds cache-specific semantics such as: batch access methods, entry eviction timeouts, locking hints and entry copy mode overrides (for safety and performance). {excerpt} |
| | | {style}{excerpt}The ObjectMap API provides a transactional map-based API that allows typical CRUD (Create, Read, Update and Delete) operations to the ObjectGrid cache. Similar to the java.util.Map interface, it also adds cache-specific semantics such as: batch access methods, entry eviction timeouts, locking hints, and entry copy mode overrides (for safety and performance). {excerpt} |
| | |
| | h3. Getting Started |
| | |
| | * [Introduction to ObjectMaps] |
| | * [ObjectMap and JavaMap interfaces] |
| | * [Using maps as FIFO queues] |
| | |
| | h3. Examples and Tutorials |
| | |
| | The following example illustrates how to obtain ObjectMap and perform storing, finding, updating, and removing object operations using ObjectMap API: |
| | {code:title=ObjectMapExample.java} |
| | import com.ibm.websphere.objectgrid.ObjectGrid; |
| | import com.ibm.websphere.objectgrid.ObjectGridManager; |
| | import com.ibm.websphere.objectgrid.ObjectGridManagerFactory; |
| | import com.ibm.websphere.objectgrid.ObjectMap; |
| | import com.ibm.websphere.objectgrid.Session; |
| | |
| | public class ObjectMapExample { |
| | |
| | public static void main(String[] args) throws Throwable { |
| | ObjectGridManager objectGridManager = ObjectGridManagerFactory.getObjectGridManager(); |
| | ObjectGrid ivObjectGrid = objectGridManager.createObjectGrid("objectgridName"); |
| | ivObjectGrid.defineMap("myMap"); |
| | ivObjectGrid.initialize(); |
| | Session ivSession = ivObjectGrid.getSession(); |
| | |
| | // Obtaining ObjectMap from ObjectGrid Session |
| | ObjectMap objectMap = ivSession.getMap("myMap"); |
| | |
| | // storing an Object |
| | ivSession.begin(); |
| | objectMap.insert("key", "value"); |
| | ivSession.commit(); |
| | |
| | // Finding an Object |
| | ivSession.begin(); |
| | String cachedObject = (String) objectMap.get("key"); |
| | ivSession.commit(); |
| | |
| | // Updating an Object |
| | ivSession.begin(); |
| | cachedObject = (String) objectMap.get("key"); |
| | cachedObject = cachedObject + "_newValue"; |
| | objectMap.put("key", cachedObject); |
| | ivSession.commit(); |
| | |
| | // Removing an Object |
| | Object removedObject = objectMap.remove("key"); |
| | } |
| | } |
| | {code} |
| | |
| | h3. Related Information |
| | |
| | * [ObjectMap API documentation|http://www.ibm.com/developerworks/wikis/objectgridprog/docs/api/com/ibm/websphere/objectgrid/ObjectMap.html] |
| | |
| | {include:OG_FOOTER} |