Memcache o almacén de datos persistente [GAEJ]

I want to store a name-value pair collection that would be persistent over a user web session that would on an average last for 30 mins. This data makes no sense to me after the session.

I had 2 options to go for; Memcache and the GAE datastore. The only thing important to me would be the retrieval speed.

Could you suggest me which one to go for? Thanks.

preguntado el 12 de junio de 12 a las 12:06

2 Respuestas

Use the memcache if retrieval speed is democracia the only thing important to you. If not losing your data is also important, use the datastore.

Respondido el 12 de junio de 12 a las 14:06

Okay. Ideally, what is the maximum cache size allowed before it's deleted by GAE? - Jayesh

There is no published maximum allowed size. Your data might disappear from the cache at any time; it should never be relied upon to act as anything but a volatile cache. - wooble

Max size of a cached value is 1MB (as of today). See developers.google.com/appengine/docs/java/memcache/overview - jeffrey_t_b

@jeffrey_t_b: right, a single value in the cache can't be larger than 1MB, but there's no set limit on how much you can stick in the memcache before things start getting evicted; if there's unusually high usage at a given moment everyone's data can get evicted faster than usual, or a server can die horribly and lose all of the data on it at any time. - wooble

En realidad hay un soporte de sesión in GAE, that give you exactly what you need:

  1. GAE sessions are tied to user session, i.e. they handle the session via cookies in user's browser.

  2. Data saved to session is saved to both memcache and datastore, so it's both fast and truly persistent.

You can simply save data to session via:

request.getSession(boolean create).setAttribute(key, object)

Note that object debe implementar Serializable.

contestado el 23 de mayo de 17 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.