Package alluxio

Class StreamCache


  • @ThreadSafe
    public final class StreamCache
    extends java.lang.Object
    Cache for storing file input and output streams. When a stream is added to the cache, the cache returns a unique ID that can be used for future lookups of the stream. The streams are automatically closed when their cache entry is invalidated or after being inactive for an extended period of time.
    • Constructor Summary

      Constructors 
      Constructor Description
      StreamCache​(long timeoutMs)
      Creates a new instance of StreamCache.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      alluxio.client.file.FileInStream getInStream​(java.lang.Integer key)  
      alluxio.client.file.FileOutStream getOutStream​(java.lang.Integer key)  
      java.io.Closeable invalidate​(java.lang.Integer key)  
      java.lang.Integer put​(alluxio.client.file.FileInStream is)  
      java.lang.Integer put​(alluxio.client.file.FileOutStream os)  
      long size()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StreamCache

        public StreamCache​(long timeoutMs)
        Creates a new instance of StreamCache.
        Parameters:
        timeoutMs - the timeout (in milliseconds) for the stream cache eviction
    • Method Detail

      • getInStream

        public alluxio.client.file.FileInStream getInStream​(java.lang.Integer key)
        Parameters:
        key - the key to get the stream for
        Returns:
        the stream or null if the cache contains no stream for the given key
      • getOutStream

        public alluxio.client.file.FileOutStream getOutStream​(java.lang.Integer key)
        Parameters:
        key - the key to get the stream for
        Returns:
        the stream or null if the cache contains no stream for the given key
      • put

        public java.lang.Integer put​(alluxio.client.file.FileInStream is)
        Parameters:
        is - the stream to cache
        Returns:
        the key for looking up the stream
      • put

        public java.lang.Integer put​(alluxio.client.file.FileOutStream os)
        Parameters:
        os - the stream to cache
        Returns:
        the key for looking up the stream
      • invalidate

        @Nullable
        public java.io.Closeable invalidate​(java.lang.Integer key)
        Parameters:
        key - the key for the stream to invalidate
        Returns:
        the invalidated stream or null if the cache contains no stream for the given key
      • size

        public long size()
        Returns:
        total size of the cache for both input streams and output streams