Using memcache in the google engine

I created an application using GAE. I expect 100k queries daily. Currently, for each query, the application must look for 4 tables and 8 diff columns before performing the necessary task.

These 4 tables are my main tables having 5k, 500, 200 and 30 entries. It is less than 1 MB (limit).

Now I want to put my master records in memcache for faster access and reduced RPC call. When some user update wizard I replaced the memcache object.

I need a community suggestion about this.

Can I change the current design?

How can I put 4 table files in memcache?

This is how the application works at the moment.

  • 100 users gain access to the same application page.
  • They provide a unique identification token and 3 more parameters (say, p1, p2 and p3).
  • My servlet is receiving a request.
  • The application retrieves the user table using the token and checks the inclusion status.
  • The application retrieves another table (say department ) and checks for the existence of p1. If there is an inclusion status check.
  • If the above value returns true, a service table is requested based on the p2 parameter to check whether this service is enabled or not for this user, and check the Service EndDate.
  • Depending on the length of p3, another table is checked for availability.
+4
source share
1 answer

You should not think about how to embed tables in memcache. Instead, use the "optimistic cache" strategy: anytime you need to perform the operation you want to cache, first try to find it in memcache, and if that fails, extract it from the data store and then save it in memcache. Here is an example:

 def cached_get(key): entity = memcache.get(str(key)) if not entity: entity = db.get(key) memcache.set(str(key), entity) return entity 

Please note, however, that the caching of individual objects is rather low - the data warehouse performs fetching quite quickly. Caching query results or displayed pages will give a much better speed improvement.

+6
source

Source: https://habr.com/ru/post/1316386/


All Articles