Class DistributedRedisSet

java.lang.Object
io.github.blyznytsiaorg.bibernate.cache.impl.DistributedRedisSet
All Implemented Interfaces:
DistributedSet

public class DistributedRedisSet extends Object implements DistributedSet
Implementation of the DistributedSet interface using Redis as the distributed cache. Provides methods for adding entities to Redis and retrieving them.
Since:
1.0
Author:
Blyzhnytsia Team
  • Field Details

    • jedis

      private final redis.clients.jedis.Jedis jedis
  • Constructor Details

    • DistributedRedisSet

      public DistributedRedisSet()
  • Method Details

    • add

      public <T> void add(Class<T> entityClass, String cacheKey, T entity)
      Adds an entity to the Redis cache.
      Specified by:
      add in interface DistributedSet
      Type Parameters:
      T - the type of the entity
      Parameters:
      entityClass - the class of the entity
      cacheKey - the cache key associated with the entity
      entity - the entity to add to the cache
      Throws:
      NullPointerException - if cacheKey or entity is null
    • get

      public <T> Optional<T> get(Class<T> entityClass, String cacheKey)
      Retrieves an entity from the Redis cache.
      Specified by:
      get in interface DistributedSet
      Type Parameters:
      T - the type of the entity
      Parameters:
      entityClass - the class of the entity
      cacheKey - the cache key associated with the entity
      Returns:
      an Optional containing the retrieved entity, or empty if not found
      Throws:
      NullPointerException - if entityClass or cacheKey is null