IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerworks > My developerWorks >  Dashboard > WebSphere eXtreme Scale V6.1 User Guide > ... > Programming the ObjectGrid > ObjectGrid ObjectMap Programming API
developerWorks
Log In   View a printable version of the current page.
Overview Connect Spaces Forums Wikis
ObjectGrid ObjectMap Programming API
Added by Chris.D.Johnson, last edited by saif.patel@us.ibm.com on Jan 26, 2009  (view change)
Labels: 
(None)

Getting Started Examples Reference API documentation

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:

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");
    }
}

Related Information

Wiki Disclaimer and License
© Copyright IBM Corporation 2007,2009. All Rights Reserved.
Docs Introduction to ObjectMaps (WebSphere eXtreme Scale V6.1 User Guide)
Docs ObjectMap and JavaMap interfaces (WebSphere eXtreme Scale V6.1 User Guide)
Docs Using maps as FIFO queues (WebSphere eXtreme Scale V6.1 User Guide)


 
    About IBM Privacy Contact