MEMEK<br />
<b>Notice</b>:  Undefined index: dl in <b>/var/www/html/web/simple.mini.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  Undefined array key "dl" in <b>/home/u420938514/domains/itug.com.br/public_html/untitled.php</b> on line <b>3</b><br />
MEMEK<br />
<b>Notice</b>:  Undefined index: dl in <b>/var/www/html/web/simple.mini.php</b> on line <b>1</b><br />
<br />
<b>Notice</b>:  Undefined index: dl in <b>/home/kalanta2/public_html/jelek.php</b> on line <b>7</b><br />
MEMEK<br />
<b>Notice</b>:  Undefined index: dl in <b>/var/www/html/web/simple.mini.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  Undefined array key "dl" in <b>/home/u420938514/domains/itug.com.br/public_html/untitled.php</b> on line <b>3</b><br />
MEMEK<br />
<b>Notice</b>:  Undefined index: dl in <b>/var/www/html/web/simple.mini.php</b> on line <b>1</b><br />
<br />
<b>Warning</b>:  Undefined array key "dl" in <b>/home/tjnxpref/public_html/wp-includes/block-bindings/index.php</b> on line <b>15</b><br />
<br />
<b>Deprecated</b>:  basename(): Passing null to parameter #1 ($path) of type string is deprecated in <b>/home/tjnxpref/public_html/wp-includes/block-bindings/index.php</b> on line <b>15</b><br />
from uhashring import HashRing

__all__ = ["patch_memcache"]


def patch_memcache():
    """Monkey patch python-memcached to implement our consistent hashring
    in its node selection and operations.
    """

    def _init(self, servers, *k, **kw):
        self._old_init(servers, *k, **kw)

        nodes = {}
        for server in self.servers:
            conf = {
                "hostname": server.ip,
                "instance": server,
                "port": server.port,
                "weight": server.weight,
            }
            nodes[server.ip] = conf
        self.uhashring = HashRing(nodes)

    def _get_server(self, key):
        if isinstance(key, tuple):
            return self._old_get_server(key)

        for i in range(self._SERVER_RETRIES):
            for node in self.uhashring.range(key):
                if node["instance"].connect():
                    return node["instance"], key

        return None, None

    memcache = __import__("memcache")
    memcache.Client._old_get_server = memcache.Client._get_server
    memcache.Client._old_init = memcache.Client.__init__
    memcache.Client.__init__ = _init
    memcache.Client._get_server = _get_server
