DATAREDIS-1085 - Support approximate trimming using XTRIM.

Original pull request: #561.
This commit is contained in:
dengliming
2020-09-11 23:54:11 +08:00
committed by Mark Paluch
parent c72a84885c
commit 99cf4a2238
17 changed files with 179 additions and 15 deletions

View File

@@ -1726,6 +1726,13 @@ public class DefaultStringRedisConnectionPipelineTests extends DefaultStringRedi
super.xTrimShouldDelegateAndConvertCorrectly();
}
@Test
public void xTrimApproximateShouldDelegateAndConvertCorrectly() {
doReturn(Arrays.asList(1L)).when(nativeConnection).closePipeline();
super.xTrimApproximateShouldDelegateAndConvertCorrectly();
}
protected List<Object> getResults() {
return connection.closePipeline();
}

View File

@@ -1846,6 +1846,13 @@ public class DefaultStringRedisConnectionPipelineTxTests extends DefaultStringRe
super.xTrimShouldDelegateAndConvertCorrectly();
}
@Test
public void xTrimApproximateShouldDelegateAndConvertCorrectly() {
doReturn(Arrays.asList(Arrays.asList(1L))).when(nativeConnection).closePipeline();
super.xTrimApproximateShouldDelegateAndConvertCorrectly();
}
@SuppressWarnings("unchecked")
protected List<Object> getResults() {
connection.exec();

View File

@@ -2169,6 +2169,15 @@ public class DefaultStringRedisConnectionTests {
Assertions.assertThat(getResults()).containsExactly(1L);
}
@Test
public void xTrimApproximateShouldDelegateAndConvertCorrectly() {
doReturn(1L).when(nativeConnection).xTrim(any(), anyLong(), anyBoolean());
actual.add(connection.xTrim("key", 2L, true));
Assertions.assertThat(getResults()).containsExactly(1L);
}
protected List<Object> getResults() {
return actual;
}

View File

@@ -1733,6 +1733,13 @@ public class DefaultStringRedisConnectionTxTests extends DefaultStringRedisConne
super.xTrimShouldDelegateAndConvertCorrectly();
}
@Test
public void xTrimApproximateShouldDelegateAndConvertCorrectly() {
doReturn(Arrays.asList(1L)).when(nativeConnection).exec();
super.xTrimApproximateShouldDelegateAndConvertCorrectly();
}
protected List<Object> getResults() {
return connection.exec();
}