user1154644
user1154644

Reputation: 4609

GAE memcache vs request session

I have a store front application deployed on GAE that allows users to view their order history. I'm trying to decide between caching the data using memcache, or just storing the data in the users session instead of hitting the datastore everytime they request a new page/set of orders. Can anyone recommend one or the other? If I used memcache, I would probably use a combination of the users ID and a hardcoded string as the key for the memcache entry.

Upvotes: 0

Views: 486

Answers (2)

koma
koma

Reputation: 6566

Simply store everything in the datastore using Objectify or another intelligent framework that will handle all the caching for you.

Most important is that you can address the entities by creating their keys and you don't have to execute any queries against the datastore because then the caching won't work. If you can compose a key for memcache based on the userId, then you can do it for the datastore.

Upvotes: 1

Andrei Volgin
Andrei Volgin

Reputation: 41089

GAE session is backed by Memcache and the Datastore:

App Engine includes an implementation of sessions, using the servlet session interface. The implementation stores session data in the App Engine datastore for persistence, and also uses memcache for speed. (documentation)

Since you need to store the orders data in the Datastore anyway, using sessions will result in saving the same data twice. So I would suggest going with the Memcache.

Upvotes: 2

Related Questions