Package mondrian.util

Class ExpiringReference<T>


  • public class ExpiringReference<T>
    extends java.lang.ref.SoftReference<T>
    An expiring reference is a subclass of SoftReference which pins the reference in memory until a certain timeout is reached. After that, the reference is free to be garbage collected if needed.

    The timeout value must be provided as a String representing both the time value and the time unit. For example, 1 second is represented as "1s". Valid time units are [d, h, m, s, ms], representing respectively days, hours, minutes, seconds and milliseconds.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) long expiry  
      (package private) T hardRef  
    • Constructor Summary

      Constructors 
      Constructor Description
      ExpiringReference​(T ref, java.lang.String timeout)
      Creates an expiring reference.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get()  
      T get​(java.lang.String timeout)  
      (package private) java.util.TimerTask getTask()  
      • Methods inherited from class java.lang.ref.Reference

        clear, clone, enqueue, isEnqueued, reachabilityFence
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • hardRef

        T hardRef
      • expiry

        long expiry
    • Constructor Detail

      • ExpiringReference

        public ExpiringReference​(T ref,
                                 java.lang.String timeout)
        Creates an expiring reference.
        Parameters:
        ref - The referent.
        timeout - The timeout to enforce, in minutes. If timeout is equal or less than 0, this means a hard reference.
    • Method Detail

      • getTask

        java.util.TimerTask getTask()
      • get

        public T get()
        Overrides:
        get in class java.lang.ref.SoftReference<T>
      • get

        public T get​(java.lang.String timeout)