Class SimpleCache

  • All Implemented Interfaces:
    IComputable<java.lang.Object,​java.lang.Object>

    public class SimpleCache
    extends java.lang.Object
    implements IComputable<java.lang.Object,​java.lang.Object>
    Simple cache that just uses a HashMap to cache objects and never releases them. This Cache is thread safe but not very high-performance.
    Author:
    Jan Ortmann
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleCache​(IComputable<java.lang.Object,​java.lang.Object> computable)  
      SimpleCache​(IComputable<java.lang.Object,​java.lang.Object> computable, int initialCapacity)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object compute​(java.lang.Object key)
      Compute an object of type V identified by the key of type K
      java.lang.Class<? super java.lang.Object> getValueClass()
      Getting the Class of the value this computable produces.
      • Methods inherited from class java.lang.Object

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

      • SimpleCache

        public SimpleCache​(IComputable<java.lang.Object,​java.lang.Object> computable)
      • SimpleCache

        public SimpleCache​(IComputable<java.lang.Object,​java.lang.Object> computable,
                           int initialCapacity)
    • Method Detail

      • compute

        public java.lang.Object compute​(java.lang.Object key)
                                 throws java.lang.InterruptedException
        Description copied from interface: IComputable
        Compute an object of type V identified by the key of type K
        Specified by:
        compute in interface IComputable<java.lang.Object,​java.lang.Object>
        Parameters:
        key - the key to identify the object
        Returns:
        the computed Object of type V
        Throws:
        java.lang.InterruptedException - When computation was interrupted
      • getValueClass

        public java.lang.Class<? super java.lang.Object> getValueClass()
        Description copied from interface: IComputable
        Getting the Class of the value this computable produces.
        Specified by:
        getValueClass in interface IComputable<java.lang.Object,​java.lang.Object>