Skip to main content

Samir Caus

Samir Caus's Public Library

Problem with session - Google App Engine for Java | Google Groups

  • I store my object in memcache using the session.getId() identifier

    of my JVM :

    import javax.cache.Cache;

    import javax.cache.CacheException;

    import javax.cache.CacheFactory;

    import javax.cache.CacheManager;



    class MyController {

    def find = {

    def session = request.getSession(true)

    def cache = CacheManager.getInstance().getCacheFactory().createCache

    (Collections.emptyMap())

    def map = new HashMap()

    for (Place place : places.getPlacesList()) {

         for (int i = 0; i < place.mapUrls.length; i++ ) {

                  map.put('cachedMapUrl'+i, place.mapUrls[i]) ;

         }

    }


    ByteArrayOutputStream baos = new ByteArrayOutputStream()

    ObjectOutputStream oos = new ObjectOutputStream(baos)

    oos.writeObject(map)

    cache.put("mapUrls", baos.toByteArray())

    CacheManager.getInstance().registerCache("_ahs" + session.getId(),

    cache)

    [places : places, jsessionId : session.getId()]

    }



    }


    2) I retrieve my object from the cache : jessionId being retrieved

    from http request params

    def changeZoom = {

    def cache = CacheManager.getInstance().getCache("_ahs" + params

    ['jsessionId'])

    def buf = (byte[]) cache.get("mapUrls")

    ByteArrayInputStream bais = new ByteArrayInputStream(buf);

    ObjectInputStream ois = new ObjectInputStream(bais);

    def  map = (HashMap) ois.readObject()

    def mapUrl = map.get('cachedMapUrl'+zoomIndex)

    }
29 Oct 09

intient (intient) on Twitter

  • Nimble 0.3-SNAPSHOT pushed to #grails plugin repo.
    "grails install-plugin nimble 0.3-SNAPSHOT" to get you started.
24 Oct 09

Creating, Getting and Deleting Data - Google App Engine - Google Code

  • For a key for an entity with an entity group parent, you can use the KeyFactory.Builder class:



    import com.google.appengine.api.datastore.Key;
    import com.google.appengine.api.datastore.KeyFactory;

    // ...
           
    Key k = new KeyFactory.Builder(Employee.class.getSimpleName(), 52234).addChild(ExpenseReport.class.getSimpleName(), "A23Z79").getKey();


    The Builder instance's addChild() method returns the Builder, so you can chain calls to add each element of the key path. To get the complete Key value for a given builder, you call the Builder's getKey() method.

getting multiple objects fails - Google App Engine for Java | Google Groups

  • The getObjectsById function hasn't been optimized to perform a batch get, so

    you're just as well-off issuing multiple calls to getObjectById. If you need

    to issue a batch get, you'll need to use the low-level API.
  • The getObjectsById function hasn't been optimized to perform a batch get, so

    you're just as well-off issuing multiple calls to getObjectById. If you need

    to issue a batch get, you'll need to use the low-level API.
  • 2 more annotations...
1 - 11 of 11
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo