Class FileBasedCache

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Iterable<org.apache.flink.api.java.tuple.Tuple2<String,​FileCacheEntry>>

    public final class FileBasedCache
    extends DoubleListLru<String,​FileCacheEntry>
    implements Closeable
    A file-granularity LRU cache. Only newly generated SSTs are written to the cache, the file reading from the remote will not. Newly generated SSTs are written to the original file system and cache simultaneously, so, the cached file can be directly deleted with persisting when evicting. The FileBasedCache, FileCacheEntry, CachedDataInputStream, and CachedDataOutputStream classes work together to implement a file-based caching mechanism in ForSt State Backend.
  • FileBasedCache manages multiple FileCacheEntry instances.
  • Each FileCacheEntry represents a cached file and can open CachedDataInputStream for reading the file.
  • CachedDataInputStream instances are created by FileCacheEntry and can read data from either the cached file or the original file, depending on the cache entry's state. It has internal stream status to indicate the current reading source.
  • CachedDataOutputStream instances are created by FileBasedCache and write data to both the original and cached files, creating a new cache entry in the cache when the writing is finished.