Interface PersistentCache

  • All Known Implementing Classes:
    AbstractPersistentCache, PersistentDiskCache, PersistentRedisCache

    public interface PersistentCache
    This interface represents a cache which survives segment store restarts. The cache is agnostic to any archive structure. Segments are only identified by their UUIDs, specified as msb and lsb parts of the segment id.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void cleanUp()
      Purges the cache entries according to the implementation policy (e.g.
      boolean containsSegment​(long msb, long lsb)
      Check if the segment exists in the cache.
      @Nullable Buffer readSegment​(long msb, long lsb, @NotNull java.util.concurrent.Callable<Buffer> loader)
      Reads the segment from cache.
      void writeSegment​(long msb, long lsb, Buffer buffer)
      Writes the segment to the cache.
    • Method Detail

      • readSegment

        @Nullable
        @Nullable Buffer readSegment​(long msb,
                                     long lsb,
                                     @NotNull
                                     @NotNull java.util.concurrent.Callable<Buffer> loader)
        Reads the segment from cache.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        loader - in case of cache miss, with loader.call() missing element will be retrieved
        Returns:
        byte buffer containing the segment data or null if the segment doesn't exist
      • containsSegment

        boolean containsSegment​(long msb,
                                long lsb)
        Check if the segment exists in the cache.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        Returns:
        true if the segment exists
      • writeSegment

        void writeSegment​(long msb,
                          long lsb,
                          Buffer buffer)
        Writes the segment to the cache.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        buffer - the byte buffer containing the segment data
      • cleanUp

        void cleanUp()
        Purges the cache entries according to the implementation policy (e.g. maximum cache size, maximum number of entries, etc.)