Class LightweightBrowserCache

  • All Implemented Interfaces:
    BrowserCache

    public class LightweightBrowserCache
    extends java.lang.Object
    implements BrowserCache
    In-memory BrowserCache. Uses an underlying cache, with ConcurrentMapCache as the default. You specify maximum bytes you want the cache to have. The default is 2Megabytes. If the cache exceeds this amount, it is wiped clean. This rather draconian approach to cache reaping is to avoid synchronization that you would normally have to do in a sophisticated cache.

    With high concurrent access, because this is not a sophisticated cache, sometimes a cache entry may be lost. It is consistent though.

    Version:
    $Revision: 1 $
    • Field Detail

      • maxBytes

        protected long maxBytes
      • bytes

        protected java.util.concurrent.atomic.AtomicLong bytes
    • Constructor Detail

      • LightweightBrowserCache

        public LightweightBrowserCache()
      • LightweightBrowserCache

        public LightweightBrowserCache​(BrowserCache cache)
    • Method Detail

      • setInternalCache

        public void setInternalCache​(BrowserCache internalCache)
      • getMaxBytes

        public long getMaxBytes()
      • setMaxBytes

        public void setMaxBytes​(long maxBytes)
      • getByteCount

        public long getByteCount()
      • put

        public BrowserCache.Entry put​(java.lang.String key,
                                      javax.ws.rs.core.MediaType mediaType,
                                      javax.ws.rs.core.MultivaluedMap<java.lang.String,​java.lang.String> headers,
                                      byte[] cached,
                                      int expires,
                                      java.lang.String etag,
                                      java.lang.String lastModified)
        Specified by:
        put in interface BrowserCache