Google App Engine.如何使用Memcache或数据存储区执行同步操作? [英] Google App Engine. How to make synchronized actions using memcache or datastore?

查看:72
本文介绍了Google App Engine.如何使用Memcache或数据存储区执行同步操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的主要目标是能够拥有一些同步方法,直到完成后,其他线程才可以访问该方法. 如果我有普通的VM-我会将此方法标记为已同步. 但是在GAE中,我有多个实例. 我所读到的所有帖子都说我应该使用内存缓存或数据存储. 但是到底如何呢?

My main goal is to be able to have some synchronized method that shouldn't be accessed by other threads until it is finished. If I had usual VM - I would mark this method as synchronized. But in GAE I have multiple instances. All posts that I read about this say that I should use memcache or datastore. But how exactly ?

推荐答案

通常,答案是重新设计该函数,因此不需要全局同步.即使您设法进行同步,也只有一个瓶颈.

Usually the answer is redesign the function so it doesn't need to be globally synchronized. Even if you manage to synchronize it, it's a single bottleneck.

您最好是在后端上实现它;您可以指定一个后端,并使您的函数调用对后端的请求.您也可以将Memcache或数据存储区用作信号灯,但是所有这些都会使您的性能降低.

You're probably best off to implement it on a backend; you can specify a single backend, and make your function call a request to the backend. You can also use memcache or the datastore as semaphore, but all of those are going to give you poor performance.

这篇关于Google App Engine.如何使用Memcache或数据存储区执行同步操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆