Skip to content

Commit 92feb11

Browse files
committed
Add SINTERCARD operation to Jedis and Lettuce set commands
1 parent ba80735 commit 92feb11

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
* @author Dennis Neufeld
8383
* @author Shyngys Sapraliyev
8484
* @author Jeonggyu Choi
85+
* @author Mingi Lee
8586
*/
8687
@NullUnmarked
8788
@SuppressWarnings({ "ConstantConditions", "deprecation" })
@@ -832,6 +833,11 @@ public Long sInterStore(byte[] destKey, byte[]... keys) {
832833
return convertAndReturn(delegate.sInterStore(destKey, keys), Converters.identityConverter());
833834
}
834835

836+
@Override
837+
public Long sInterCard(byte[]... keys) {
838+
return convertAndReturn(delegate.sInterCard(keys), Converters.identityConverter());
839+
}
840+
835841
@Override
836842
public Boolean sIsMember(byte[] key, byte[] value) {
837843
return convertAndReturn(delegate.sIsMember(key, value), Converters.identityConverter());
@@ -1824,6 +1830,11 @@ public Long sInterStore(String destKey, String... keys) {
18241830
return sInterStore(serialize(destKey), serializeMulti(keys));
18251831
}
18261832

1833+
@Override
1834+
public Long sInterCard(String... keys) {
1835+
return sInterCard(serializeMulti(keys));
1836+
}
1837+
18271838
@Override
18281839
public Boolean sIsMember(String key, String value) {
18291840
return sIsMember(serialize(key), serialize(value));

src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
* @author Dennis Neufeld
6868
* @author Shyngys Sapraliyev
6969
* @author Tihomir Mateev
70+
* @author Mingi Lee
7071
* @since 2.0
7172
*/
7273
@Deprecated
@@ -890,6 +891,13 @@ default Long sInterStore(byte[] destKey, byte[]... keys) {
890891
return setCommands().sInterStore(destKey, keys);
891892
}
892893

894+
/** @deprecated in favor of {@link RedisConnection#setCommands()}}. */
895+
@Override
896+
@Deprecated
897+
default Long sInterCard(byte[]... keys) {
898+
return setCommands().sInterCard(keys);
899+
}
900+
893901
/** @deprecated in favor of {@link RedisConnection#setCommands()}}. */
894902
@Override
895903
@Deprecated

src/main/java/org/springframework/data/redis/connection/StringRedisConnection.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
* @author ihaohong
7575
* @author Shyngys Sapraliyev
7676
* @author Jeonggyu Choi
77+
* @author Mingi Lee
7778
* @see RedisCallback
7879
* @see RedisSerializer
7980
* @see StringRedisTemplate
@@ -1169,6 +1170,17 @@ String bLMove(@NonNull String sourceKey, @NonNull String destinationKey, @NonNul
11691170
*/
11701171
Long sInterStore(@NonNull String destKey, @NonNull String @NonNull... keys);
11711172

1173+
/**
1174+
* Returns the cardinality of the set which would result from the intersection of all the given sets.
1175+
*
1176+
* @param keys must not be {@literal null}.
1177+
* @return
1178+
* @see <a href="https://redis.io/commands/sintercard">Redis Documentation: SINTERCARD</a>
1179+
* @see RedisSetCommands#sInterCard(byte[]...)
1180+
* @since 3.4
1181+
*/
1182+
Long sInterCard(@NonNull String @NonNull... keys);
1183+
11721184
/**
11731185
* Union all sets at given {@code keys}.
11741186
*

0 commit comments

Comments
 (0)