Just saw this configuration in one of the project setting.py
在项目setup .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),
],
}
}
Just curious why have tuples inside LOCATION
? what's the "1" in the tuple for?
只是好奇为什么在里面有元组?元组中的“1”是做什么用的?
1 个解决方案
#1
2
Here in python-memcached, location
ultimately gets sent to this function. It seems its a redundant (but helpful reminder) that a weight param exists.
在python-memcached内,位置最终会被发送到这个函数。它似乎是一个冗余的(但很有帮助的提醒)权重参数的存在。
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.
"""
#1
2
Here in python-memcached, location
ultimately gets sent to this function. It seems its a redundant (but helpful reminder) that a weight param exists.
在python-memcached内,位置最终会被发送到这个函数。它似乎是一个冗余的(但很有帮助的提醒)权重参数的存在。
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.
"""