Class TimedBuffer<O,​K>


  • public class TimedBuffer<O,​K>
    extends Object
    • Constructor Detail

      • TimedBuffer

        public TimedBuffer()
        Creates a timed buffer that does not make use of a timeout
      • TimedBuffer

        public TimedBuffer​(long timeoutMillis)
        Creates a timed buffer with the given timeout in milliseconds. If this value is zero or negative, no timeout will be used.
        Parameters:
        timeoutMillis - timeout in milliseconds.
    • Method Detail

      • get

        public Object get​(O obj,
                          K key)
      • set

        public void set​(O obj,
                        K key,
                        Object value)
      • remove

        public void remove​(O obj,
                           K key)
      • clear

        public void clear​(O obj)
        This method removes all keys (and thus values) associated with the given object.
        Parameters:
        obj - the key to clear
      • clearAll

        public void clearAll()
        This method clears everything in this buffer.
      • clearAll

        public void clearAll​(K key)
        This method clears all values associated with the given key across all objects.
        Parameters:
        key - the value to clear
      • cull

        public void cull()
        This method will remove all entries that aged beyond the assigned timeout. As this method has a linear complexity, don't call it too often. This method is a O(1) no-op if no timeout is defined for this method.