Class FileCacheProvider

  • All Implemented Interfaces:
    CacheProvider

    public class FileCacheProvider
    extends java.lang.Object
    implements CacheProvider
    File cache provider.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Entirely clear the cache content
      void definePaths()
      Define the root path
      <T> T get​(java.lang.String key)
      Getting an entry on the cache
      java.nio.file.Path getCachePath​(java.lang.String key)
      Returns the path from the given key
      java.util.List<java.lang.String> getKeys()
      Returns all keys from a given cache
      <T> void lockAndSet​(java.lang.String key, T entry)
      Applies a lock to a cache's file
      void parseConfig​(java.io.BufferedReader br)
      Parses the config file
      void remove​(java.lang.String key)
      Removes an entry in the cache
      <T> void set​(java.lang.String key, T entry)
      Adding an entry to the cache
      void setCacheFileEntry​(java.io.File current, java.nio.file.Path path)
      Sets a file cache entry
      void setExpiry​(int expiry)
      Reconfigure the expiry after
      void shutdown()
      No shutdown operation for this class
      • Methods inherited from class java.lang.Object

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

      • FileCacheProvider

        public FileCacheProvider()
    • Method Detail

      • parseConfig

        public void parseConfig​(java.io.BufferedReader br)
                         throws java.io.IOException
        Parses the config file
        Parameters:
        br -
        Throws:
        java.io.IOException
      • definePaths

        public void definePaths()
        Define the root path
      • setCacheFileEntry

        public void setCacheFileEntry​(java.io.File current,
                                      java.nio.file.Path path)
        Sets a file cache entry
        Parameters:
        current -
        path -
      • getCachePath

        public java.nio.file.Path getCachePath​(java.lang.String key)
                                        throws java.io.IOException
        Returns the path from the given key
        Parameters:
        key -
        Returns:
        Path
        Throws:
        java.io.IOException
      • get

        public <T> T get​(java.lang.String key)
                  throws CacheException
        Description copied from interface: CacheProvider
        Getting an entry on the cache
        Specified by:
        get in interface CacheProvider
        Type Parameters:
        T - cache entry
        Parameters:
        key - key of the cache entry
        Returns:
        Object
        Throws:
        CacheException - when there is cache issues getting by key
      • lockAndSet

        public <T> void lockAndSet​(java.lang.String key,
                                   T entry)
                            throws CacheException
        Applies a lock to a cache's file
        Parameters:
        key -
        entry -
        Throws:
        CacheException
      • set

        public <T> void set​(java.lang.String key,
                            T entry)
                     throws CacheException
        Description copied from interface: CacheProvider
        Adding an entry to the cache
        Specified by:
        set in interface CacheProvider
        Type Parameters:
        T - cache entry
        Parameters:
        key - key of the cache entry
        entry - cache entry
        Throws:
        CacheException - when there is cache issues setting an element
      • remove

        public void remove​(java.lang.String key)
                    throws CacheException
        Description copied from interface: CacheProvider
        Removes an entry in the cache
        Specified by:
        remove in interface CacheProvider
        Parameters:
        key - key of the cache entry
        Throws:
        CacheException - when there is cache issues removing an entry
      • clear

        public void clear()
        Description copied from interface: CacheProvider
        Entirely clear the cache content
        Specified by:
        clear in interface CacheProvider
      • shutdown

        public void shutdown()
        No shutdown operation for this class
        Specified by:
        shutdown in interface CacheProvider
      • getKeys

        public java.util.List<java.lang.String> getKeys()
        Description copied from interface: CacheProvider
        Returns all keys from a given cache
        Specified by:
        getKeys in interface CacheProvider
        Returns:
        List
      • setExpiry

        public void setExpiry​(int expiry)
        Description copied from interface: CacheProvider
        Reconfigure the expiry after
        Specified by:
        setExpiry in interface CacheProvider
        Parameters:
        expiry - cache time life in minutes