If you cache is in memory (ie not stored memcache or the datastore)
then if the instance holding the hashmap is shutdown from inactivity
(oftern in less than two minutes) you will lose everything.

Stuff in memcache will dissappear too, though for other reasons
(memory pressure, time ...) but
will tend to stay around longer than instance memory, and is shared
between all instances. However it will dissapear too
at some point so you need to deal with that as well.

The only thing guarunteed to hand around is data you persist in the
data store

When you say "remote retrieval takes 6-7 secs" I assume you don't mean
from the datastore?

T

On Nov 6, 7:48 am, Peter Warren <pe...@nomad.org> wrote:
> 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