I have a hashmap on app engine that loses its contents after 5-10
minutes.  Does app engine release unused objects after a timeout?  I
couldn't find any relevant documentation.

My caching class (code below) holds references to uploaded objects and
also stores a serialized version of the uploaded object in the
datastore.  When a client requests an object, the cache is checked
first.  If the object isn't in the cache, the object is retrieved from
the datastore.

When the cache is empty, remote retrieval of an object (1k in size)
takes about 6-7 seconds, I assume for the fetch from datastore and
deserialization.  When the object is in cache it takes around 160ms.
(#s are from Firebug.)

I confirmed with debug code that my hashmap is indeed being emptied
after a while and that it's not client caching or other code issues.

I cannot reproduce this locally with the app engine plugin for
eclipse.

Is there a way to make the app engine leave my hashmap alone?

Thanks for any help,
Peter

-----
    private static ConfiguratorStorage storage = new
ConfiguratorStorage();

    private HashMap<ConfiguratorID, Configurator> idToConfiguratorMap;

    private ConfiguratorStorage() {
        idToConfiguratorMap = new HashMap<ConfiguratorID, Configurator>
();
    }

    public static ConfiguratorStorage getInstance() {
        return storage;
    }

    public Configurator getConfigurator(ConfiguratorID id) {
        Configurator configurator = idToConfiguratorMap.get(id);
        if (configurator == null) {
            PersistenceManager persistenceManager =
Persistence.getPersistenceManagerFactory().getPersistenceManager();
            try {
                ConfiguratorDAO wrapper =
persistenceManager.getObjectById(ConfiguratorDAO.class, id.toString
());
                configurator = wrapper.getConfigurator();
                idToConfiguratorMap.put(configurator.getConfiguratorID
(), configurator);
            } catch (JDOObjectNotFoundException nfe) {
                // do nothing
            } finally {
                persistenceManager.close();
            }
        }
        return configurator;
    }

    public void saveConfigurator(Configurator configurator, String
xml) throws IOException {
        idToConfiguratorMap.put(configurator.getConfiguratorID(),
configurator);
        PersistenceManager persistenceManager =
Persistence.getPersistenceManagerFactory().getPersistenceManager();
        ConfiguratorDAO wrapper = new ConfiguratorDAO(configurator);
        try {
            persistenceManager.makePersistent(wrapper);
        } finally {
            persistenceManager.close();
        }
    }
-----
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to