刚刚在项目setting.py之一中看到了此配置
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'KEY_PREFIX' : 'projectabc:',
'LOCATION': [
('10.1.1.1:11211', 1),
('10.1.1.2:11211', 1),
('10.1.1.3:11211', 1),
('10.1.1.4:11211', 1),
],
}
}
只是好奇为什么LOCATION
里面有元组?元组中的“1”有什么用?
最佳答案
在 python-memcached 中,location
最终被发送到此函数。重量参数的存在似乎是多余的(但很有帮助的提醒)。
def set_servers(self, servers):
"""
Set the pool of servers used by this client.
@param servers: an array of servers.
Servers can be passed in two forms:
1. Strings of the form C{"host:port"}, which implies a default weight of 1.
2. Tuples of the form C{("host:port", weight)}, where C{weight} is
an integer weight value.
"""
关于django memcached 设置位置列表有元组吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13869998/