【问题标题】:django memcached setting location list has tuples?django memcached 设置位置列表有元组吗?
【发布时间】:2012-12-13 22:56:56
【问题描述】:

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

【问题讨论】:

    标签: django memcached setting


    【解决方案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.
        """
    

    【讨论】:

      猜你喜欢
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 2017-07-07
      • 2012-08-14
      • 2023-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多