@Nullable @Override public ValueEncoding encodingOf(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.objectEncoding(key), connection.clusterGetNodeForKey(key)) .mapValue(JedisConverters::toEncoding); }
@Nullable @Override public Duration idletime(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectIdletime(key), connection.clusterGetNodeForKey(key)) .mapValue(Converters::secondsToDuration); }
@Nullable @Override public Long refcount(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectRefcount(key), connection.clusterGetNodeForKey(key)) .getValue(); }
@Override public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(serializedValue, "Serialized value must not be null!"); if (ttlInMillis > Integer.MAX_VALUE) { throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE."); } connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback<String>) client -> { if (!replace) { return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue); } return JedisConverters.toString(this.connection.execute("RESTORE", key, Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes ("REPLACE")))); }, connection.clusterGetNodeForKey(key)); }
@Nullable @Override public Duration idletime(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectIdletime(key), connection.clusterGetNodeForKey(key)) .mapValue(Converters::secondsToDuration); }
@Nullable @Override public Long refcount(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectRefcount(key), connection.clusterGetNodeForKey(key)) .getValue(); }
@Nullable @Override public ValueEncoding encodingOf(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.objectEncoding(key), connection.clusterGetNodeForKey(key)) .mapValue(JedisConverters::toEncoding); }
@Nullable @Override public ValueEncoding encodingOf(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.objectEncoding(key), connection.clusterGetNodeForKey(key)) .mapValue(JedisConverters::toEncoding); }
@Nullable @Override public Long refcount(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectRefcount(key), connection.clusterGetNodeForKey(key)) .getValue(); }
@Nullable @Override public Duration idletime(byte[] key) { Assert.notNull(key, "Key must not be null!"); return connection.getClusterCommandExecutor() .executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectIdletime(key), connection.clusterGetNodeForKey(key)) .mapValue(Converters::secondsToDuration); }
@Override public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(serializedValue, "Serialized value must not be null!"); if (ttlInMillis > Integer.MAX_VALUE) { throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE."); } connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback<String>) client -> { if (!replace) { return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue); } return JedisConverters.toString(this.connection.execute("RESTORE", key, Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes ("REPLACE")))); }, connection.clusterGetNodeForKey(key)); }
@Override public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolean replace) { Assert.notNull(key, "Key must not be null!"); Assert.notNull(serializedValue, "Serialized value must not be null!"); if (ttlInMillis > Integer.MAX_VALUE) { throw new UnsupportedOperationException("Jedis does not support ttlInMillis exceeding Integer.MAX_VALUE."); } connection.getClusterCommandExecutor().executeCommandOnSingleNode((JedisClusterCommandCallback<String>) client -> { if (!replace) { return client.restore(key, Long.valueOf(ttlInMillis).intValue(), serializedValue); } return JedisConverters.toString(this.connection.execute("RESTORE", key, Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes ("REPLACE")))); }, connection.clusterGetNodeForKey(key)); }