Class DefaultHalResourceCache

  • All Implemented Interfaces:
    Cache

    public class DefaultHalResourceCache
    extends java.lang.Object
    implements Cache
    • Field Detail

      • capacity

        protected int capacity
      • secondsToLive

        protected long secondsToLive
    • Constructor Detail

      • DefaultHalResourceCache

        public DefaultHalResourceCache()
      • DefaultHalResourceCache

        public DefaultHalResourceCache​(int capacity,
                                       long secondsToLive)
    • Method Detail

      • getCapacity

        public int getCapacity()
      • setCapacity

        public void setCapacity​(int capacity)
      • getSecondsToLive

        public long getSecondsToLive()
      • setSecondsToLive

        public void setSecondsToLive​(long secondsToLive)
      • size

        public int size()
      • put

        public void put​(java.lang.String id,
                        java.lang.Object resource)
        Description copied from interface: Cache
        Put a resource into the cache.
        Specified by:
        put in interface Cache
        Parameters:
        id - the id of the resource
        resource - the resource to cache
      • remove

        public void remove​(java.lang.String id)
      • get

        public java.lang.Object get​(java.lang.String id)
        Description copied from interface: Cache
        Get a resource by id.
        Specified by:
        get in interface Cache
        Parameters:
        id - the id of the resource
        Returns:
        the resource or null if non is found or the resource time to live expired
      • destroy

        public void destroy()
        Description copied from interface: Cache
        Destroy cache.
        Specified by:
        destroy in interface Cache
      • ensureCapacityLimit

        protected void ensureCapacityLimit()