2

刚刚在其中一个项目 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”是做什么用的?

4

1 回答 1

2

在 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.
    """
于 2012-12-13T23:36:34.160 回答