django memcached 设置位置列表有元组吗?

标签 django memcached setting

刚刚在项目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/

相关文章:

python - 为什么我无法访问django 模板中的外键信息。

python - 导入错误 : cannot import name UserSerializer while creating a demo rest api

ruby-on-rails - Rails 4 俄罗斯套娃缓存如何防止踩踏?

ruby-on-rails - Rails 3 和 Memcached - 智能缓存,永不过期

android - 检查设备是否锁定在纵向模式

amazon-elastic-beanstalk - terraform aws_elastic_beanstalk_environment SSL PolicyNames

python - Django Nose 这个测试怎么写?

python - Whitenoise、Mezzanine、Django -ImportError : cannot import name ManifestStaticFilesStorage

python - 将静态 Django 数据库加载到内存中

ios - 使用 WLAN 和蜂窝设置获取应用程序