Class DirectBufferCache


  • public class DirectBufferCache
    extends Object
    A non-blocking buffer cache where entries are indexed by a path and are made up of a subsequence of blocks in a fixed large direct buffer. An ideal application is a file system cache, where the path corresponds to a file location.

    To reduce contention, entry allocation and eviction execute in a sampling fashion (entry hits modulo N). Eviction follows an LRU approach (oldest sampled entries are removed first) when the cache is out of capacity

    In order to expedite reclamation, cache entries are reference counted as opposed to garbage collected.

    Author:
    Jason T. Greene
    • Constructor Detail

      • DirectBufferCache

        public DirectBufferCache​(int sliceSize,
                                 int slicesPerPage,
                                 int maxMemory)
      • DirectBufferCache

        public DirectBufferCache​(int sliceSize,
                                 int slicesPerPage,
                                 int maxMemory,
                                 org.xnio.BufferAllocator<ByteBuffer> bufferAllocator)
      • DirectBufferCache

        public DirectBufferCache​(int sliceSize,
                                 int slicesPerPage,
                                 int maxMemory,
                                 org.xnio.BufferAllocator<ByteBuffer> bufferAllocator,
                                 int maxAge)