prettyClouds commented on a change in pull request #5058:
URL: https://github.com/apache/geode/pull/5058#discussion_r421917238



##########
File path: 
geode-redis/src/main/java/org/apache/geode/redis/internal/executor/set/RedisSet.java
##########
@@ -98,6 +102,156 @@ public static boolean del(Region<ByteArrayWrapper, 
RedisSet> region,
     }
   }
 
+  public static int scard(Region<ByteArrayWrapper, RedisSet> region, 
ByteArrayWrapper key) {
+    RedisSet redisSet = region.get(key);
+    if (redisSet != null) {
+      return redisSet.size();
+    } else {
+      return -1;
+    }
+  }
+
+  public static boolean sismember(Region<ByteArrayWrapper, RedisSet> region,
+      ByteArrayWrapper key, ByteArrayWrapper member) {
+    RedisSet redisSet = region.get(key);
+    if (redisSet != null) {
+      return redisSet.contains(member);
+    } else {
+      return false;
+    }
+  }
+
+  public static Collection<ByteArrayWrapper> 
srandmember(Region<ByteArrayWrapper, RedisSet> region,
+      ByteArrayWrapper key, int count) {
+    RedisSet redisSet = region.get(key);
+    if (redisSet != null) {
+      return redisSet.srandmember(count);
+    } else {
+      return null;
+    }
+  }
+
+  public static Collection<ByteArrayWrapper> spop(Region<ByteArrayWrapper, 
RedisSet> region,
+      ByteArrayWrapper key, int popCount) {
+    RedisSet redisSet = region.get(key);
+    if (redisSet != null) {
+      return redisSet.doSpop(region, key, popCount);
+    } else {
+      return null;
+    }
+  }
+
+  public static List<Object> sscan(Region<ByteArrayWrapper, RedisSet> region,
+      ByteArrayWrapper key, Pattern matchPattern, int count, int cursor) {
+    RedisSet RedisSet = region.get(key);
+    if (RedisSet != null) {
+      return RedisSet.doSscan(matchPattern, count, cursor);
+    } else {
+      return null;

Review comment:
       does the calling code differentiate between null and an empty 
collection? If not, can we just return an empty collection and get rid of the 
upstream null checks.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to