Implemented LASTSAVE

This commit is contained in:
Jonathan Leibiusky
2010-08-08 13:20:43 -03:00
parent bf3094f051
commit bb5fe63b72
3 changed files with 26 additions and 0 deletions

View File

@@ -523,4 +523,8 @@ public class Client extends Connection {
public void bgrewriteaof() {
sendCommand("BGREWRITEAOF");
}
public void lastsave() {
sendCommand("LASTSAVE");
}
}

View File

@@ -617,4 +617,9 @@ public class Jedis {
client.bgrewriteaof();
return client.getStatusCodeReply();
}
public int lastsave() {
client.lastsave();
return client.getIntegerReply();
}
}

View File

@@ -2,6 +2,8 @@ package redis.clients.jedis.tests.commands;
import org.junit.Test;
import redis.clients.jedis.JedisException;
public class PersistenceControlCommandsTest extends JedisCommandTestBase {
@Test
public void save() {
@@ -21,4 +23,19 @@ public class PersistenceControlCommandsTest extends JedisCommandTestBase {
assertEquals("Background append only file rewriting started", status);
}
@Test
public void lastsave() throws InterruptedException {
int before = jedis.lastsave();
String st = "";
while (!st.equals("OK")) {
try {
Thread.sleep(1000);
st = jedis.save();
} catch (JedisException e) {
}
}
int after = jedis.lastsave();
assertTrue((after - before) > 0);
}
}