See the WebSphere eXtreme Scale Wiki for links to eXtreme Scale Version 7.0 documentation.
If you log in
with your developerWorks ID, you can leave comments and feedback for the development team.
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).
Getting Started
Examples and Tutorials
The following example illustrates how to obtain ObjectMap and perform storing, finding, updating, and removing object operations using ObjectMap API:
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();
ObjectMap objectMap = ivSession.getMap("myMap");
ivSession.begin();
objectMap.insert("key", "value");
ivSession.commit();
ivSession.begin();
String cachedObject = (String) objectMap.get("key");
ivSession.commit();
ivSession.begin();
cachedObject = (String) objectMap.get("key");
cachedObject = cachedObject + "_newValue";
objectMap.put("key", cachedObject);
ivSession.commit();
Object removedObject = objectMap.remove("key");
}
}
Related Information
© Copyright IBM Corporation 2007,2009. All Rights Reserved.