Class CacheLRUWrapper


  • public class CacheLRUWrapper
    extends java.lang.Object
    This class helps maintain the ordering of most recently use items across multiple jvm instances.
    • Constructor Detail

      • CacheLRUWrapper

        public CacheLRUWrapper()
    • Method Detail

      • getInstance

        public static CacheLRUWrapper getInstance()
        Returns an instance of the policy.
        Returns:
        an instance of the policy
      • getWindowsShortcutList

        public java.io.File getWindowsShortcutList()
      • load

        public void load()
        Update map for keeping track of recently used items.
      • store

        public boolean store()
        Write file to disk.
        Returns:
        true if properties were successfully stored, false otherwise
      • addEntry

        public boolean addEntry​(java.lang.String key,
                                java.lang.String path)
        This adds a new entry to file.
        Parameters:
        key - key we want path to be associated with.
        path - path to cache item.
        Returns:
        true if we successfully added to map, false otherwise.
      • removeEntry

        public boolean removeEntry​(java.lang.String key)
        This removed an entry from our map.
        Parameters:
        key - key we want to remove.
        Returns:
        true if we successfully removed key from map, false otherwise.
      • updateEntry

        public boolean updateEntry​(java.lang.String oldKey)
        This updates the given key to reflect it was recently accessed.
        Parameters:
        oldKey - Key we wish to update.
        Returns:
        true if we successfully updated value, false otherwise.
      • getLRUSortedEntries

        public java.util.List<java.util.Map.Entry<java.lang.String,​java.lang.String>> getLRUSortedEntries()
        Return a copy of the keys available.
        Returns:
        List of Strings sorted by ascending order.
      • lock

        public void lock()
        Lock the file to have exclusive access.
      • unlock

        public void unlock()
        Unlock the file.
      • getValue

        public java.lang.String getValue​(java.lang.String key)
        Return the value of given key.
        Parameters:
        key - key of property
        Returns:
        value of given key, null otherwise.
      • containsKey

        public boolean containsKey​(java.lang.String key)
      • containsValue

        public boolean containsValue​(java.lang.String value)
      • generateKey

        public java.lang.String generateKey​(java.lang.String path)
        Generate a key given the path to file. May or may not generate the same key given same path.
        Parameters:
        path - Path to generate a key with.
        Returns:
        String representing the a key.