@Override public Boolean setNX(byte[] key, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().setnx(key, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().setnx(key, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().setnx(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
private void setnx0(String key, String value) { t.setnx(key, value); }
@Override public Boolean multiSetIfAbsent(Map<? extends K, ? extends V> map) { Transaction transaction = this.mockJedis.multi(); for(Entry<? extends K, ? extends V> entry : map.entrySet()) { K key = entry.getKey(); V value = entry.getValue(); byte[] keyBytes = this.template.keySerializer.serialize(key); byte[] valueBytes = this.template.valueSerializer.serialize(value); transaction.setnx(keyBytes, valueBytes); } transaction.exec(); return true; }
@Override public Boolean setNX(byte[] key, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().setnx(key, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().setnx(key, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().setnx(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Boolean setNX(byte[] key, byte[] value) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(value, "Value must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().setnx(key, value), JedisConverters.longToBoolean())); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().setnx(key, value), JedisConverters.longToBoolean())); return null; } return JedisConverters.toBoolean(connection.getJedis().setnx(key, value)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }