All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.server.resp.commands.generic.KEYS Maven / Gradle / Ivy

There is a newer version: 15.1.4.Final
Show newest version
package org.infinispan.server.resp.commands.generic;

import org.infinispan.container.entries.CacheEntry;
import org.infinispan.server.iteration.IterationManager;
import org.infinispan.server.resp.Resp3Handler;
import org.infinispan.server.resp.commands.iteration.BaseIterationCommand;

import java.util.ArrayList;
import java.util.List;

/**
 * Returns all keys matching pattern.
 *
 * @see Redis Documentation
 * @since 15.0
 */
public class KEYS extends BaseIterationCommand {

   public KEYS() {
      super(2, 0, 0, 0);
   }

   @Override
   protected boolean writeCursor() {
      return false;
   }

   @Override
   protected IterationManager retrieveIterationManager(Resp3Handler handler) {
      return handler.respServer().getIterationManager();
   }

   @Override
   protected String cursor(List raw) {
      return "0";
   }

   @Override
   protected byte[] getMatch(List arguments) {
      return arguments.get(0);
   }

   @Override
   protected List writeResponse(List response) {
      List output = new ArrayList<>(response.size());
      for (CacheEntry entry : response) {
         output.add((byte[]) entry.getKey());
      }
      return output;
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy