Class MemCache

  • All Implemented Interfaces:
    Cache

    public class MemCache
    extends java.lang.Object
    implements Cache
    Class used to cache values in a local database file.
    • Constructor Summary

      Constructors 
      Constructor Description
      MemCache()  
      MemCache​(int maxHandles, long maxTTL)  
      MemCache​(int maxHandles, long maxTTL, boolean trackHits)
      Deprecated.
      MemCache​(long maxTTL)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Remove all values from the cache
      void close()  
      byte[][] getCachedValues​(byte[] handle, byte[][] reqTypes, int[] reqIndexes)
      Returns any non-expired handle values that are in the caches storage.
      boolean isCachedNotFound​(byte[][] values)
      Returns true if this return value of getCachedValues indicates a cached value of HANDLE_NOT_FOUND
      void removeHandle​(byte[] handle)
      Remove one handle from the cache
      void setCachedNotFound​(byte[] handle, int ttl)
      Returns true if this handle should have a cached HANDLE_NOT_FOUND.
      void setCachedValues​(byte[] handle, HandleValue[] newValues, byte[][] newTypeList, int[] newIndexList)
      Store the given handle values after a query for the handle.
      void setMaximumHandles​(int maxHandles)
      Set the maximum size for the cache by the number of handles.
      void setMaximumSize​(int maxSize)
      Set the maximum size for the cache by the number of bytes used for storage.
      • Methods inherited from class java.lang.Object

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

      • MemCache

        public MemCache​(int maxHandles,
                        long maxTTL)
      • MemCache

        @Deprecated
        public MemCache​(int maxHandles,
                        long maxTTL,
                        boolean trackHits)
        Deprecated.
      • MemCache

        public MemCache​(long maxTTL)
      • MemCache

        public MemCache()
    • Method Detail

      • isCachedNotFound

        public boolean isCachedNotFound​(byte[][] values)
        Description copied from interface: Cache
        Returns true if this return value of getCachedValues indicates a cached value of HANDLE_NOT_FOUND
        Specified by:
        isCachedNotFound in interface Cache
      • getCachedValues

        public byte[][] getCachedValues​(byte[] handle,
                                        byte[][] reqTypes,
                                        int[] reqIndexes)
                                 throws java.lang.Exception
        Returns any non-expired handle values that are in the caches storage. A null return value indicates that the requested values aren't in the cache. Returning the an array of values (including an array of zero length) indicates that the returned values are the only values from the requested set (ie the handle doesn't have any more values from the requested set). ***** Speed is important in this method *****
        Specified by:
        getCachedValues in interface Cache
        Throws:
        java.lang.Exception
      • setCachedNotFound

        public void setCachedNotFound​(byte[] handle,
                                      int ttl)
                               throws java.lang.Exception
        Description copied from interface: Cache
        Returns true if this handle should have a cached HANDLE_NOT_FOUND. Pass time-to-live.
        Specified by:
        setCachedNotFound in interface Cache
        Throws:
        java.lang.Exception
      • removeHandle

        public void removeHandle​(byte[] handle)
                          throws java.lang.Exception
        Description copied from interface: Cache
        Remove one handle from the cache
        Specified by:
        removeHandle in interface Cache
        Throws:
        java.lang.Exception
      • setCachedValues

        public void setCachedValues​(byte[] handle,
                                    HandleValue[] newValues,
                                    byte[][] newTypeList,
                                    int[] newIndexList)
                             throws java.lang.Exception
        Store the given handle values after a query for the handle. The query was performed with the given type-list and index-list. ***** Speed is less important in this method *****
        Specified by:
        setCachedValues in interface Cache
        Throws:
        java.lang.Exception
      • clear

        public void clear()
                   throws java.lang.Exception
        Remove all values from the cache
        Specified by:
        clear in interface Cache
        Throws:
        java.lang.Exception
      • setMaximumHandles

        public void setMaximumHandles​(int maxHandles)
        Set the maximum size for the cache by the number of handles.
        Specified by:
        setMaximumHandles in interface Cache
      • setMaximumSize

        public void setMaximumSize​(int maxSize)
        Set the maximum size for the cache by the number of bytes used for storage.
        Specified by:
        setMaximumSize in interface Cache
      • close

        public void close()
        Specified by:
        close in interface Cache