Set the value at key ``name`` to ``value``

        :param ex: sets an expire flag on key ``name`` for ``ex`` seconds.
        :param px: sets an expire flag on key ``name`` for ``px`` milliseconds.
        :param nx: if set to True, set the value at key ``name`` to ``value``
            if it does not already exist.
        :param xx: if set to True, set the value at key ``name`` to ``value``
            if it already exists.

def set(self, name, value, ex=None, px=None, nx=False, xx=False):
        """Set the value at key ``name`` to ``value``

        :param ex: sets an expire flag on key ``name`` for ``ex`` seconds.
        :param px: sets an expire flag on key ``name`` for ``px`` milliseconds.
        :param nx: if set to True, set the value at key ``name`` to ``value``
            if it does not already exist.
        :param xx: if set to True, set the value at key ``name`` to ``value``
            if it already exists.
        """
        pieces = [name, value]
        if ex:
            pieces.append('EX')
            if isinstance(ex, datetime.timedelta):
                ex = ex.seconds + ex.days * 24 * 3600
            pieces.append(ex)
        if px:
            pieces.append('PX')
            if isinstance(px, datetime.timedelta):
                ms = int(px.microseconds / 1000)
                px = (px.seconds + px.days * 24 * 3600) * 1000 + ms
            pieces.append(px)

        if nx:
            pieces.append('NX')
        if xx:
            pieces.append('XX')
        return self.execute('set', *pieces)