0

In my gae application, a user can do an action (buy something). I need that information stored persistently and available imediately on all requests from all sessions of this user on multiple devices/browsers. I'm using webapp2_extras sessions. The way I'm thinking of doing this is either:

1) adding the action_happened field to the User model and make it available in the session by adding it to the list in webapp2_extras.auth['user_attributes'] config. But this doesn't work unless the user is logged out on all sessions.

or 2) create a memcache entry (backed by the datastore) for each user like user_id_action_happened and check if it is true or false on each request. This is my preffered method.

Is there any other way to do this?

user3526468
  • 334
  • 5
  • 14
  • No, I think `2)` is your best approach -- the core ideas is to have that entry in the datastore and query it on each request, memcache's just a further (probably worthwhile:-) optimization but doesn't change the functionality. – Alex Martelli Mar 15 '15 at 02:16

1 Answers1

0

I think storing in database and doing a query on each request is the most natural option.

Don't know about your full requirements and specifications, but for keeping the sessions synchronized I think a solution like firebase makes a lot of sense, though it might be overkill in your case.

Jaime Gómez
  • 6,961
  • 3
  • 40
  • 41
  • Ok, thanks for your answer! I'll try then to modify my design so as to allow this information only on specific user requests. – user3526468 Mar 16 '15 at 17:09