NDB Caching When Using Projected Queries

前端 未结 2 1968
清酒与你
清酒与你 2021-01-15 22:34

Could not find this specific question asked before yet. How does App Engine\'s NDB handle caching when using projected queries vs. full entity queries?

For example,

相关标签:
2条回答
  • 2021-01-15 22:51

    As far as I'm aware, query results are only cached in in-context cache, but results are not fetched from cache for queries.

    key.get() will be cached and retrieved from cache, but query.get() won't be retrieved from cache.

    https://developers.google.com/appengine/docs/python/ndb/cache

    From the docs: Queries do not look up values in any cache. However, query results are written back to the in-context cache if the cache policy says so (but never to Memcache).

    To answer the question regarding what you'll be getting, in both queries it appears that the results will be fetched from the datastore and not from cache.

    0 讨论(0)
  • 2021-01-15 23:06

    Projection query results are never cached. It would not be right if a get by key were to ever return a projection result. So no worries.

    0 讨论(0)
提交回复
热议问题