来自 Memcache 的 JDO 批量 PUT
为了减少我消耗的数据存储 PUT 的数量,我 希望更频繁地使用内存缓存。想法是存储 在将所有实体写入之前,实体在内存缓存中保存 n 分钟 数据存储并清除缓存。
我有两个问题:
有没有办法批量 PUT 缓存中的每个实体?我相信 makePersistentAll() 并不是真正的批量保存,而是保存每个 单独来看不是吗?
其次,您可以将“回调”功能放置在实体上 你把它们放在内存缓存中吗?即如果我将一个实体添加到缓存中 (有 2 分钟的过期增量)我可以告诉 AppEngine 保存 实体被驱逐时到数据存储区?
谢谢!
In an effort to reduce the number of datastore PUTs I am consuming I
wish to use the memcache much more frequently. The idea being to store
entities in the memcache for n minutes before writing all entities to
the datastore and clearing the cache.
I have two questions:
Is there a way to batch PUT every entity in the cache? I believe
makePersistentAll() is not really batch saving but rather saving each
individually is it not?
Secondly is there a "callback" function you can place on entities as
you place them in the memcache? I.e. If I add an entity to the cache
(with a 2 minute expiration delta) can I tell AppEngine to save the
entity to the datastore when it is evicted?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
makePersistentAll 确实执行了批量 PUT,日志应该足够清楚地告诉您
makePersistentAll does indeed do a batch PUT, which the log ought to tell you clear enough
无法在 App Engine 中获取内存缓存的全部内容。无论如何,这都是一个坏主意 - 项目可以随时从内存缓存中逐出,包括在插入它们时和尝试将数据写入数据存储之间。相反,使用 memcache 作为读取缓存,并立即将数据写入数据存储(如果可能,使用批处理操作)。
There's no way to fetch the entire contents of memcache in App Engine. In any case, this is a bad idea - items can be evicted from memcache at any time, including between when you inserted them and when you tried to write the data to the datastore. Instead, use memcache as a read cache, and write data to the datastore immediately (using batch operations when possible).