@Override public byte[] get(byte[] key) { Assert.notNull(key, "Key must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().get(key))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().get(key))); return null; } return connection.getJedis().get(key); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public List<byte[]> sPop(byte[] key, long count) { Assert.notNull(key, "Key must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().spop(key, count), ArrayList::new)); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().spop(key, count), ArrayList::new)); return null; } return new ArrayList<>(connection.getJedis().spop(key, count)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public String scriptLoad(byte[] script) { Assert.notNull(script, "Script must not be null!"); if (isQueueing() || isPipelined()) { throw new UnsupportedOperationException(); } try { return JedisConverters.toString(connection.getJedis().scriptLoad(script)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public byte[] hGet(byte[] key, byte[] field) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hget(key, field))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hget(key, field))); return null; } return connection.getJedis().hget(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Properties info(String section) { Assert.notNull(section, "Section must not be null!"); if (isPipelined() || isQueueing()) { throw new UnsupportedOperationException(); } try { return JedisConverters.toProperties(connection.getJedis().info(section)); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long hIncrBy(byte[] key, byte[] field, long delta) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hincrBy(key, field, delta))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrBy(key, field, delta))); return null; } return connection.getJedis().hincrBy(key, field, delta); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long zCount(byte[] key, Range range) { Assert.notNull(key, "Key must not be null!"); if (isPipelined() || isQueueing()) { throw new UnsupportedOperationException( "ZCOUNT not implemented in jedis for binary protocol on transaction and pipeline"); } // TODO: Implement zcount for pipeline/tx. byte[] min = JedisConverters.boundaryToBytesForZRange(range.getMin(), JedisConverters.NEGATIVE_INFINITY_BYTES); byte[] max = JedisConverters.boundaryToBytesForZRange(range.getMax(), JedisConverters.POSITIVE_INFINITY_BYTES); return connection.getJedis().zcount(key, min, max); }
@Override public Double hIncrBy(byte[] key, byte[] field, double delta) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Field must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hincrByFloat(key, field, delta))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hincrByFloat(key, field, delta))); return null; } return connection.getJedis().hincrByFloat(key, field, delta); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public byte[] bRPopLPush(int timeout, byte[] srcKey, byte[] dstKey) { Assert.notNull(srcKey, "Source key must not be null!"); Assert.notNull(dstKey, "Destination key must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().brpoplpush(srcKey, dstKey, timeout))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().brpoplpush(srcKey, dstKey, timeout))); return null; } return connection.getJedis().brpoplpush(srcKey, dstKey, timeout); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Nullable @Override public Long refcount(byte[] key) { Assert.notNull(key, "Key must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().objectRefcount(key))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().objectRefcount(key))); return null; } return connection.getJedis().objectRefcount(key); } catch (Exception ex) { throw connection.convertJedisAccessException(ex); } }
@Override public Boolean hExists(byte[] key, byte[] field) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(field, "Fields must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().hexists(key, field))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().hexists(key, field))); return null; } return connection.getJedis().hexists(key, field); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long zRank(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().zrank(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().zrank(key, value))); return null; } return connection.getJedis().zrank(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Double zScore(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().zscore(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().zscore(key, value))); return null; } return connection.getJedis().zscore(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long rPushX(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().rpushx(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().rpushx(key, value))); return null; } return connection.getJedis().rpushx(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public byte[] getSet(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().getSet(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().getSet(key, value))); return null; } return connection.getJedis().getSet(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Long append(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().append(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().append(key, value))); return null; } return connection.getJedis().append(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Boolean sIsMember(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().sismember(key, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().sismember(key, value))); return null; } return connection.getJedis().sismember(key, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public byte[] rPopLPush(byte[] srcKey, byte[] dstKey) { Assert.notNull(srcKey, "Source key must not be null!"); Assert.notNull(dstKey, "Destination key must not be null!"); try { if (isPipelined()) { pipeline(connection.newJedisResult(connection.getRequiredPipeline().rpoplpush(srcKey, dstKey))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().rpoplpush(srcKey, dstKey))); return null; } return connection.getJedis().rpoplpush(srcKey, dstKey); } catch (Exception ex) { throw convertJedisAccessException(ex); } }
@Override public Double zIncrBy(byte[] key, double increment, 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().zincrby(key, increment, value))); return null; } if (isQueueing()) { transaction(connection.newJedisResult(connection.getRequiredTransaction().zincrby(key, increment, value))); return null; } return connection.getJedis().zincrby(key, increment, value); } catch (Exception ex) { throw convertJedisAccessException(ex); } }