Add Redis 2.6 dump and restore commands to Connections
DATAREDIS-182
This commit is contained in:
@@ -584,6 +584,26 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return delegate.zUnionStore(destKey, sets);
|
||||
}
|
||||
|
||||
public Boolean pExpire(byte[] key, long millis) {
|
||||
return delegate.pExpire(key, millis);
|
||||
}
|
||||
|
||||
public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
|
||||
return delegate.pExpireAt(key, unixTimeInMillis);
|
||||
}
|
||||
|
||||
public Long pTtl(byte[] key) {
|
||||
return delegate.pTtl(key);
|
||||
}
|
||||
|
||||
public byte[] dump(byte[] key) {
|
||||
return delegate.dump(key);
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
|
||||
delegate.restore(key, ttlInMillis, serializedValue);
|
||||
}
|
||||
|
||||
//
|
||||
// String methods
|
||||
//
|
||||
@@ -1167,18 +1187,6 @@ public class DefaultStringRedisConnection implements StringRedisConnection {
|
||||
return execute(command, serializeMulti(args));
|
||||
}
|
||||
|
||||
public Boolean pExpire(byte[] key, long millis) {
|
||||
return delegate.pExpire(key, millis);
|
||||
}
|
||||
|
||||
public Boolean pExpireAt(byte[] key, long unixTimeInMillis) {
|
||||
return delegate.pExpireAt(key, unixTimeInMillis);
|
||||
}
|
||||
|
||||
public Long pTtl(byte[] key) {
|
||||
return delegate.pTtl(key);
|
||||
}
|
||||
|
||||
public Boolean pExpire(String key, long millis) {
|
||||
return pExpire(serialize(key), millis);
|
||||
}
|
||||
|
||||
@@ -60,4 +60,8 @@ public interface RedisKeyCommands {
|
||||
List<byte[]> sort(byte[] key, SortParameters params);
|
||||
|
||||
Long sort(byte[] key, SortParameters params, byte[] storeKey);
|
||||
|
||||
byte[] dump(byte[] key);
|
||||
|
||||
void restore(byte[] key, long ttlInMillis, byte[] serializedValue);
|
||||
}
|
||||
@@ -823,6 +823,14 @@ public class JedisConnection implements RedisConnection {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public byte[] dump(byte[] key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public DataType type(byte[] key) {
|
||||
try {
|
||||
if (isQueueing()) {
|
||||
|
||||
@@ -355,6 +355,14 @@ public class JredisConnection implements RedisConnection {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public byte[] dump(byte[] key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
return new LinkedHashSet<byte[]>(jredis.keys(pattern));
|
||||
|
||||
@@ -591,6 +591,30 @@ public class LettuceConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] dump(byte[] key) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(getAsyncConnection().dump(key));
|
||||
return null;
|
||||
}
|
||||
return getConnection().dump(key);
|
||||
} catch (Exception ex) {
|
||||
throw convertLettuceAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(getAsyncConnection().restore(key, ttlInMillis, serializedValue));
|
||||
return;
|
||||
}
|
||||
getConnection().restore(key, ttlInMillis, serializedValue);
|
||||
} catch (Exception ex) {
|
||||
throw convertLettuceAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
|
||||
@@ -647,6 +647,30 @@ public class SrpConnection implements RedisConnection {
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] dump(byte[] key) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(pipeline.dump(key));
|
||||
return null;
|
||||
}
|
||||
return client.dump(key).data();
|
||||
} catch (Exception ex) {
|
||||
throw convertSrpAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void restore(byte[] key, long ttlInMillis, byte[] serializedValue) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
pipeline(pipeline.restore(key, ttlInMillis, serializedValue));
|
||||
return;
|
||||
}
|
||||
client.restore(key, ttlInMillis, serializedValue);
|
||||
} catch (Exception ex) {
|
||||
throw convertSrpAccessException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public DataType type(byte[] key) {
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
|
||||
Reference in New Issue
Block a user