ai.grakn.redismock.commands.RO_smembers Maven / Gradle / Ivy
package ai.grakn.redismock.commands;
import ai.grakn.redismock.RedisBase;
import ai.grakn.redismock.Response;
import ai.grakn.redismock.Slice;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import java.util.LinkedList;
import java.util.List;
import static ai.grakn.redismock.Utils.deserializeObject;
class RO_smembers extends AbstractRedisOperation {
RO_smembers(RedisBase base, List params) {
super(base, params, 1, null, null);
}
Slice response() {
Slice key = params().get(0);
Slice data = base().rawGet(key);
//Has to be a list because Jedis can only deserialize lists
LinkedList set;
if (data != null) {
set = new LinkedList<>(deserializeObject(data));
} else {
set = Lists.newLinkedList();
}
ImmutableList.Builder builder = new ImmutableList.Builder();
set.forEach(element -> builder.add(Response.bulkString(element)));
return Response.array(builder.build());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy