2012-12-13 22 views
2

剛看到該項目的一個這種配置setting.pydjango memcached設置位置列表有元組?

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」是什麼?

回答

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. 
    """