是否可以在 App Engine 数据存储上同时使用 db 和 ndb 进行缓存?
Is it possible to use both db and ndb with caching on app engine datatore?
我有一个旧版应用程序 (webapp2),它使用 db 写入数据存储。我写了一个新的只读烧瓶 API,它在同一个数据存储上使用 ndb。
没有为 ndb 查询缓存通过 db 的写入,这就是问题所在。我发现这个解决方法可以禁用 ndb 的缓存读取,How to clear cache for specific model in NDB
但我想知道是否有另一种方法可以指导管理这个问题,或者解决方案是完全迁移到 ndb 吗?
不,当两个客户端都处于活动状态时无法使用缓存,因为 ndb
客户端通过 memcache
使用缓存而 db
客户端不使用。来自 The Python DB Client Library for Cloud Datastore:
Note: Developers building new applications are strongly encouraged to use the NDB Client Library, which has several
benefits compared to this client library, such as automatic entity
caching via the Memcache API. If you are currently using the older DB
Client Library, read the DB to NDB Migration Guide.
尝试使用 ndb
缓存意味着每个客户端看到的同一实体可能存在差异。
由于 db
已被标记为已弃用一段时间,我宁愿花时间迁移到 ndb
,在大多数情况下这不是一项艰巨的任务。除了 运行 官方支持的解决方案之外,您还可以提高性能并可能降低成本。恕我直言,非常值得。
我有一个旧版应用程序 (webapp2),它使用 db 写入数据存储。我写了一个新的只读烧瓶 API,它在同一个数据存储上使用 ndb。
没有为 ndb 查询缓存通过 db 的写入,这就是问题所在。我发现这个解决方法可以禁用 ndb 的缓存读取,How to clear cache for specific model in NDB
但我想知道是否有另一种方法可以指导管理这个问题,或者解决方案是完全迁移到 ndb 吗?
不,当两个客户端都处于活动状态时无法使用缓存,因为 ndb
客户端通过 memcache
使用缓存而 db
客户端不使用。来自 The Python DB Client Library for Cloud Datastore:
Note: Developers building new applications are strongly encouraged to use the NDB Client Library, which has several benefits compared to this client library, such as automatic entity caching via the Memcache API. If you are currently using the older DB Client Library, read the DB to NDB Migration Guide.
尝试使用 ndb
缓存意味着每个客户端看到的同一实体可能存在差异。
由于 db
已被标记为已弃用一段时间,我宁愿花时间迁移到 ndb
,在大多数情况下这不是一项艰巨的任务。除了 运行 官方支持的解决方案之外,您还可以提高性能并可能降低成本。恕我直言,非常值得。