3

I'm looking into using gcloud node api to access the datastore api but was curious if it supported query caching in a similar manner to ndb? If not, what's the best way to make sure repeated queries are cached?

user257543
  • 881
  • 1
  • 14
  • 35
  • if not I'm thinking of using amazon elasticache and node-memcached as a caching layer. I'm just not sure how I will handle the caching logic. Maybe hash the gql queries as keys and serialized the json results from datastore into memcached? – user257543 Apr 09 '15 at 19:58
  • maybe something like this? https://github.com/BryanDonovan/node-cache-manager – user257543 Apr 09 '15 at 20:30
  • As an interesting note, ndb does not cache query results. There would be no easy way for it to know what newly created entities match the given query. It does cache the individual entities. Something to think about is that ndb does use a two-phase commit when updating the cache to make sure that future get calls don't get out of date entities. – Patrick Costello May 08 '15 at 01:03

3 Answers3

1

As far as I know, gcloud-node isn't planning to be a full-on ORM (like ndb is for Python). Also, as Patrick Costello noted in the comments above, NDB doesn't cache query results, but individual entities instead.

I think if you want caching of query results (or individual entities), you'd have to manually cache these by running your own Memcache server (http://memcached.org/) and interacting with it using memcached (https://www.npmjs.com/package/memcached)

JJ Geewax
  • 10,342
  • 1
  • 37
  • 49
1

I ended up using NsqlCache-datastore which is integrated into gstore-node. Guide: https://medium.com/google-cloud/how-to-add-a-cache-layer-to-the-google-datastore-in-node-js-ffb402cd0e1c

user257543
  • 881
  • 1
  • 14
  • 35
0

Looks like I can use the memcache app engine service accessible through this node library: https://github.com/GoogleCloudPlatform/appengine-nodejs

user257543
  • 881
  • 1
  • 14
  • 35