Class PipelineExecutor

java.lang.Object
com.github.darksoulq.abyssallib.common.database.nosql.redis.PipelineExecutor

public class PipelineExecutor extends Object
A fluent builder for executing multiple Redis commands in a single batch (Pipelining).

Pipelining significantly improves performance by sending multiple commands to the server without waiting for individual replies.

  • Constructor Details

    • PipelineExecutor

      public PipelineExecutor(Database database)
      Constructs a new PipelineExecutor.
      Parameters:
      database - The target Database.
  • Method Details

    • set

      public PipelineExecutor set(String key, String value)
      Queues a SET command.
      Parameters:
      key - The key.
      value - The value.
      Returns:
      This executor instance.
    • setex

      public PipelineExecutor setex(String key, int seconds, String value)
      Queues a SETEX (Set with Expiry) command.
      Parameters:
      key - The key.
      seconds - Expiration in seconds.
      value - The value.
      Returns:
      This executor instance.
    • del

      public PipelineExecutor del(String... keys)
      Queues a DEL command for one or more keys.
      Parameters:
      keys - The keys to delete.
      Returns:
      This executor instance.
    • hset

      public PipelineExecutor hset(String key, String field, String value)
      Queues a Hash SET command for a single field.
      Parameters:
      key - The hash key.
      field - The field name.
      value - The field value.
      Returns:
      This executor instance.
    • hset

      public PipelineExecutor hset(String key, Map<String,String> hash)
      Queues a Hash SET command for multiple fields.
      Parameters:
      key - The hash key.
      hash - A map of fields and values.
      Returns:
      This executor instance.
    • hdel

      public PipelineExecutor hdel(String key, String... fields)
      Queues a Hash DEL command.
      Parameters:
      key - The hash key.
      fields - The fields to remove.
      Returns:
      This executor instance.
    • lpush

      public PipelineExecutor lpush(String key, String... values)
      Queues a List Left Push command.
      Parameters:
      key - The list key.
      values - The values to push.
      Returns:
      This executor instance.
    • rpush

      public PipelineExecutor rpush(String key, String... values)
      Queues a List Right Push command.
      Parameters:
      key - The list key.
      values - The values to push.
      Returns:
      This executor instance.
    • sadd

      public PipelineExecutor sadd(String key, String... members)
      Queues a Set Add command.
      Parameters:
      key - The set key.
      members - The members to add.
      Returns:
      This executor instance.
    • srem

      public PipelineExecutor srem(String key, String... members)
      Queues a Set Remove command.
      Parameters:
      key - The set key.
      members - The members to remove.
      Returns:
      This executor instance.
    • expire

      public PipelineExecutor expire(String key, int seconds)
      Queues an EXPIRE command.
      Parameters:
      key - The key.
      seconds - Time to live in seconds.
      Returns:
      This executor instance.
    • execute

      public void execute()
      Executes all queued operations synchronously.
    • executeAsync

      public CompletableFuture<Void> executeAsync()
      Executes all queued operations asynchronously using the database thread pool.
      Returns:
      A CompletableFuture representing the pending execution.