'Set a key/value pair in memcache
:param key: key
:param value: value
:param serialize: if True, value is serialized with JSON before sending
to memcache, or with pickle if configured to use
pickle instead of JSON (to avoid cache poisoning)
:param time: the time to live
:param min_compress_len: minimum compress length, this parameter was
added to keep the signature compatible with
python-memcached interface. This
implementation ignores it.'

def set(self, key, value, serialize=True, time=0, min_compress_len=0):

    key = md5hash(key)
    timeout = sanitize_timeout(time)
    flags = 0
    if (serialize and self._allow_pickle):
        value = pickle.dumps(value, PICKLE_PROTOCOL)
        flags |= PICKLE_FLAG
    elif serialize:
        value = json.dumps(value)
        flags |= JSON_FLAG
    for (server, fp, sock) in self._get_conns(key):
        try:
            with Timeout(self._io_timeout):
                sock.sendall(('set    %s    %d    %d    %s\r\n%s\r\n' % (key, flags, timeout, len(value), value)))
                fp.readline()
                self._return_conn(server, fp, sock)
                return
        except (Exception, Timeout) as e:
            self._exception_occurred(server, e, sock=sock, fp=fp)
