Add Redis 2.6 dump and restore commands to Connections

DATAREDIS-182
This commit is contained in:
Jennifer Hickey
2013-06-16 13:20:52 -07:00
parent 5817e24b9e
commit ff60d0d290
18 changed files with 437 additions and 48 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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()) {

View File

@@ -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));

View File

@@ -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()) {

View File

@@ -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()) {