def msetnx(self, *args, **kwargs):
        """
        Sets key/values based on a mapping if none of the keys are already set.
        Mapping can be supplied as a single dictionary argument or as kwargs.
        Returns a boolean indicating if the operation was successful.
        """
        if args:
            if len(args) != 1 or not isinstance(args[0], dict):
                raise RedisError('MSETNX requires **kwargs or a single dict arg')
            mapping = args[0]
        else:
            mapping = kwargs

        if len(mapping) == 0:
            raise ResponseError("wrong number of arguments for 'msetnx' command")

        for key in mapping.keys():
            if self._encode(key) in self.redis:
                return False
        for key, value in mapping.items():
            self.set(key, value)

        return True
def msetnx ( self , * args , ** kwargs ) : if args : if len ( args ) != 1 or not isinstance ( args [ 0 ] , dict ) : raise RedisError ( 'MSETNX requires **kwargs or a single dict arg' ) mapping = args [ 0 ] else : mapping = kwargs if len ( mapping ) == 0 : raise ResponseError ( "wrong number of arguments for 'msetnx' command" ) for key in mapping . keys ( ) : if self . _encode ( key ) in self . redis : return False for key , value in mapping . items ( ) : self . set ( key , value ) return True
Sets key/values based on a mapping if none of the keys are already set.
        Mapping can be supplied as a single dictionary argument or as kwargs.
        Returns a boolean indicating if the operation was successful.