如何保留使用 memcache 的 get_multi() 函数获取的值的顺序?默认情况下,返回的顺序是随机的。谢谢。
最佳答案
Python 的 Memcache 库返回一个字典,而 python 中的字典是无序的,因此您必须手动以正确的顺序从字典中获取值:
result = cache.get_multi(keys)
values = [result.get(key) for key in keys]
关于Python memcache 在 get_multi() 中保留顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4372870/