Class RedisCacheService.Builder<V>

java.lang.Object
com.helixframework.cache.redis.RedisCacheService.Builder<V>
Type Parameters:
V - The type of values stored in the cache
Enclosing class:
RedisCacheService<V>

public static class RedisCacheService.Builder<V> extends Object
Builder class for constructing instances of RedisCacheService.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • name

      public RedisCacheService.Builder<V> name(String name)
      Sets the name of the cache.
      Parameters:
      name - the name to assign to the cache, must not be null or empty
      Returns:
      the current Builder instance for method chaining
    • jedisPool

      public RedisCacheService.Builder<V> jedisPool(redis.clients.jedis.JedisPool jedisPool)
      Sets the JedisPool instance used for managing Redis connections.
      Parameters:
      jedisPool - the JedisPool instance to be used, must not be null
      Returns:
      the current Builder instance for method chaining
    • serializer

      public RedisCacheService.Builder<V> serializer(com.helixframework.cache.CacheValueSerializer<V> serializer)
      Sets the serializer used to handle the serialization and deserialization of cache values. This serializer will be used when interacting with the cache.
      Parameters:
      serializer - the CacheValueSerializer instance responsible for handling serialization and deserialization of cache values, must not be null
      Returns:
      the current Builder instance for method chaining
    • meterRegistry

      public RedisCacheService.Builder<V> meterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry)
      Sets the optional MeterRegistry instance used to record metrics.
      Parameters:
      meterRegistry - the MeterRegistry instance to be used for collecting metrics, must not be null
      Returns:
      the current Builder instance for method chaining
    • ttl

      Sets the optional time-to-live (TTL) for cache entries. The TTL specifies the duration after which a cache entry will expire and be removed from the cache.
      Parameters:
      ttl - the duration of the time-to-live, must not be null
      Returns:
      the current Builder instance for method chaining
    • keyPrefix

      public RedisCacheService.Builder<V> keyPrefix(String keyPrefix)
      Sets the key prefix to be used for all cache keys. The key prefix is prepended to every cache key to provide a namespacing mechanism, preventing key collisions in the shared Redis store.
      Parameters:
      keyPrefix - the key prefix to set, must not be null
      Returns:
      the current Builder instance for method chaining
    • enableClear

      public RedisCacheService.Builder<V> enableClear(boolean enableClear)
      Enables or disables the clear operation for the cache.
      Parameters:
      enableClear - a boolean value indicating whether the clear operation should be enabled. If true, the cache can be cleared; if false, the clear operation will be disabled.
      Returns:
      the current Builder instance for method chaining
    • build

      public RedisCacheService<V> build()
      Constructs an instance of RedisCacheService using the provided builder configuration. This method validates the builder's state before creating the service.
      Returns:
      a new instance of RedisCacheService with the configured parameters
      Throws:
      IllegalArgumentException - if the cache name is null or empty
      IllegalStateException - if the JedisPool is not configured