Set multiple keys to multiple values only if none
of the keys already exist.

This is O(N^2) but redis is O(N), not sure how they do that.
187304
function msetnx() {
  var args = slice.call(arguments)
    , i
    , req;

  // got a req object
  if(typeof args[args.length -1] === 'object') {
    req = args.pop();
  }

  for(i = 0;i < args.length;i += 2) {
    if(this.keyExists(args[i], req)) {
      return 0;
    }
  }

  for(i = 0;i < args.length;i += 2) {
    this.setKey(args[i], args[i + 1], undefined, undefined, undefined, req);
  }

  return 1;
}
1250603
def set_if_empty(*keys, value: nil, &block)
      return unless deep_find(@settings, keys.last.to_s).nil?
      block ? set(*keys, &block) : set(*keys, value: value)
    end
312368
def set(key, opts = nil)
      fail ArgumentError, 'Second argument must be a hash' unless opts.is_a?(Hash)
      path  = key_endpoint + key
      payload = {}
      [:ttl, :value, :dir, :prevExist, :prevValue, :prevIndex].each do |k|
        payload[k] = opts[k] if opts.key?(k)
      end
      response = api_execute(path, :put, params: payload)
      Response.from_http_response(response)
    end
779125
def set_value(cache, key, value):
    
    with cache as redis_connection:
        return redis_connection.set(key, value)
772298
def decrement(self, key, value=1):
        
        return self._memcache.decr(self._prefix + key, value)
83585
function increment(redisClient, amount, keyPrepend, key, callback) {

    if (typeof amount !== 'number') {
        callback("increment amount is not number");
        return;
    }

    var multi = redisClient.multi();

    // Chain each redis command.
    incrementMinute(multi, amount, keyPrepend, key);
    incrementHour(multi, amount, keyPrepend, key);
    incrementDays(multi, amount, keyPrepend, key);
    incrementWeeks(multi, amount, keyPrepend, key);

    // Do it
    multi.exec(callback);

}
185287
def set_to(cls, name, num):
        """"""
        if num < 0:
            raise CounterValueError('Counter[%s] can not be set to %s' % (
                                    name, num))
        else:
            counter = cls.collection.find_and_modify(
                {'name': name},
                {'$set': {'seq': num}},
                new=True,
                upsert=True
            )
            return counter['seq']
69279
def set(key, value, overwrite: true)
      result = if overwrite
        self.connection.hset(@key, key, value)
      else
        self.connection.hsetnx(@key, key, value)
      end

      return coerce_bool(result)
    end
819516
function set($key, $value)
    {
        $serializedValue = $this->getDataInterchange()->makeForward($value);

        try {
            $this->client->set($this->_getKey($key), $serializedValue);
        } catch (\Exception $e) {
            throw new exWriteError('Error While Writing To Redis Client.', $e->getCode(), $e);
        }

        return $this;
    }
1244069
def reorder_keys(self, keys):
        ''''''
        if len(keys) != len(self._set):
            raise ValueError('The supplied number of keys does not match.')
        if set(keys) != self._set:
            raise ValueError('The supplied keys do not match the current set of keys.')
        self._keys = list(keys)
745605
def set(self, key, value):
        ""
        # if key already in data, update indexes
        if not isinstance(value, dict):
            raise BadValueError(
                'The value {} is incorrect.'
                ' Values should be strings'.format(value))
        _value = deepcopy(value)
        if key in self.data:
            self.delete_from_index(key)
        self.data[key] = _value
        self.update_index(key, _value)
1044961
function setValue(name, stat, value, gran, timestamp, callback) {
        if(typeof gran == 'string') {
            gran = util.getUnitDesc(gran)
        }
        var key = getGranKey(name, gran, timestamp);
        redis.hset(key, stat, value, callback)
    }
917429
def fromkeys(cls, seq, value=None, **kwargs):
        
        other = cls(**kwargs)
        other.update(((key, value) for key in seq))

        return other
543755
function hmset(key /* field-1, value-1, field-N, value-N, req */) {
  var args = slice.call(arguments, 1)
    , req = typeof args[args.length - 1] === 'object'
        ? args.pop() : null
    , val = this.getKey(key, req)
    , i;

  if(!val) {
    val = new HashMap();
    this.setKey(key, val, undefined, undefined, undefined, req);
  }
  for(i = 0;i < args.length;i+=2) {
    val.setKey(args[i], args[i + 1]);
  }
  return OK;
}
1234533
def msetnx(self, key, value, *pairs):
        
        if len(pairs) % 2 != 0:
            raise TypeError("length of pairs must be even number")
        return self.execute(b'MSETNX', key, value, *pairs)
413901
function set($key, $value, $expire = 0)
    {
        if ($expire <= 0)
        {
            $expire = 0x7fffffff;
        }
        return $this->redis->setex($key, $expire, serialize($value));
    }
1372759
public function setnx($key, $value)
    {
        try {
            return $this->redis->setnx($key, $value);
        } catch (\RedisException $e) {
            die("Error!: " . $e->getMessage() . "<br/>");
        }
    }