Class IdempotencyManager

java.lang.Object
com.loomcache.server.handler.IdempotencyManager
All Implemented Interfaces:
AutoCloseable

public class IdempotencyManager extends Object implements AutoCloseable
Manages server-side request deduplication for idempotent operations.

Tracks completed requests by client ID + request ID and returns cached responses for retried requests. Uses LRU eviction when cache is full and a background cleanup thread for expired entries.

Thread-safe: uses ReentrantLock for coordinated operations and ConcurrentHashMap for the underlying cache.

  • Constructor Details

    • IdempotencyManager

      public IdempotencyManager()
      Creates a new IdempotencyManager with default TTL (60s) and cache size (100,000).
    • IdempotencyManager

      public IdempotencyManager(long ttlMillis, int maxCacheSize)
      Creates a new IdempotencyManager with custom TTL and max cache size.
      Parameters:
      ttlMillis - TTL for cached responses in milliseconds (must be positive)
      maxCacheSize - maximum number of entries in the cache (must be positive)
      Throws:
      InvalidConfigurationException - if ttlMillis or maxCacheSize is zero or negative
    • IdempotencyManager

      public IdempotencyManager(long ttlMillis, int maxCacheSize, @Nullable io.micrometer.core.instrument.MeterRegistry meterRegistry)
  • Method Details