Question

Just saw this configuration in one of the project 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),
        ],
    }
}

Just curious why have tuples inside LOCATION? what's the "1" in the tuple for?

Was it helpful?

Solution

Here in python-memcached, location ultimately gets sent to this function. It seems its a redundant (but helpful reminder) that a weight param exists.

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.
    """
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top