Looking for advice on best way to use memcache/datastore w front-end/back-end

55 views
Skip to first unread message

Keith Chima

unread,
Jul 30, 2015, 12:44:44 AM7/30/15
to Google App Engine
So I have a rest service that is powered by the datastore. We have a angular front-end and java backend, and use REST to access the datastore data. To keep the front-end up-to-date, I want to access the datastore data once per day, and store once per day.

I assume I should access it once at the beginning of the day and store it in the memcache. Then, I should access the memcache every time a user loads the page.

Assuming this is correct, should I access the memcache from the java end and make a rest call every time the user loads the page, or should I access the memcache directly from the front-end?

Thanks,
-Keith

Mihail Russu

unread,
Jul 30, 2015, 2:36:46 AM7/30/15
to Google App Engine, keith...@gmail.com
Not sure what you're using to access the datastore but assuming it's objectify, have you looked at this doc? Your "get by key" entities could be automatically cached anyway.

be sure that your application behaves acceptably when the memcache value is suddenly not available. Values can expire from the memcache at any time, and may be expired prior to the expiration deadline set for the value

So it's probably not a good idea to export something to memcache once a day as it's not guaranteed that your data will stay there for any amount of time at all (also, it's not clear what you mean by "accessing memcache directly from the front-end", how would you go about that?). Instead, you could implement a handler on java end that will check some memcache keys and if the data exist - return it to the user but if the data doesn't exist - query the datastore, store the result in the memcache for next requests and return the data to the user. This, depending on the usage and the implementation could save you a lot of datastore reads but ofcourse check the above links for possible caveats.

Thanks,
Mihail.
Reply all
Reply to author
Forward
0 new messages