Class CaffeineCache

java.lang.Object
com.saicone.delivery4j.MessageChannel.Cache
com.saicone.delivery4j.cache.CaffeineCache

public class CaffeineCache extends MessageChannel.Cache
Caffeine integration for message ID caching.
  • Constructor Details

    • CaffeineCache

      public CaffeineCache(long duration, @NotNull @NotNull TimeUnit unit)
      Constructs a caffeine cache with provided expiration.
      Parameters:
      duration - the length of time after a message ID is automatically removed.
      unit - the unit that duration is expressed in.
  • Method Details

    • save

      protected void save(int id)
      Description copied from class: MessageChannel.Cache
      Save message ID.
      Specified by:
      save in class MessageChannel.Cache
      Parameters:
      id - the ID of the message to save.
    • contains

      public boolean contains(int id)
      Description copied from class: MessageChannel.Cache
      Check if the current cache contains the provided message ID.
      Specified by:
      contains in class MessageChannel.Cache
      Parameters:
      id - the ID of the message.
      Returns:
      true if the message is already saved, false otherwise.
    • clear

      public void clear()
      Description copied from class: MessageChannel.Cache
      Clear the current cache instance values.
      Specified by:
      clear in class MessageChannel.Cache