Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何保留使用 memcache 的 get_multi() 函数获取的值的顺序?默认情况下,返回的顺序是随机的。谢谢。
Python 的 Memcache 库返回一个字典,而 Python 中的字典是无序的,因此您必须手动以正确的顺序从字典中获取值:
result = cache.get_multi(keys) values = [result.get(key) for key in keys]
我记得 memcache 有标志 GET PRESERVE ORDER,尝试将其添加到函数标志