写入Memcache除了1MB之外还有其他限制吗?

2024-09-30 18:34:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我有个奇怪的问题。在任务中,我从数据存储中提取数据并将其异步写入memcache:

ke = database.Events.query(database.Events.eventid.IN(eventslist))
eventskeys = ke.fetch(len(eventslist),keys_only = True)

data = ndb.get_multi(eventskeys)

eventsdic = {}

for event in data:
    eventsdic.update({event.eventid: event.participants})

client = memcache.Client()

rpc = memcache.create_rpc()     
response = client.set_multi_async(eventsdic, time=3600, rpc=rpc)

事件列表中有20项。我这样做是为了大约500个项目分散在一个队列中的不同任务上。你知道吗

我没有任何错误。但我注意到,在第一次尝试中,500个事件中只有300个真正存在于memcache中。如果我只对memcache中还没有的事件进行2-3次重试,那么一段时间后memcache中就有100%的事件了。你知道吗

但我真的不明白,为什么第一次尝试就不行?你知道吗


Tags: 数据clienteventdata事件rpceventsmulti
1条回答
网友
1楼 · 发布于 2024-09-30 18:34:03

可能是因为memcache“监视”你的数据。经常使用的物品不太可能被逐出。它(据我所知)不仅仅是一个FIFO类型的系统

对我来说,这不是一个“问题”,因为如果我把一些东西放进memcache,它就不在那里,当我后来要求它的时候。我将使用我设置的回退机制来应对这种情况。当您请求时,您不能简单地假设任何内容都将在memcache中。你知道吗

https://developers.google.com/appengine/articles/scaling/memcache

The tradeoff is that data held in memcache is transient and is evicted as the system runs out of memcache space. On rare occasions, all memcached data can be evicted at once.

相关问题 更多 >