Package org.jboss.resteasy.client.jaxrs.cache

## Class LightweightBrowserCache

- java.lang.Object
- - org.jboss.resteasy.client.jaxrs.cache.LightweightBrowserCache

- All Implemented Interfaces:
    `BrowserCache`

      public class LightweightBrowserCache
      extends 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 $
  Author:
    Bill Burke

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.jboss.resteasy.client.jaxrs.cache.BrowserCache

      `BrowserCache.Entry, BrowserCache.Header`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected AtomicLong` | `bytes` |
    `protected BrowserCache` | `internalCache` |
    `protected long` | `maxBytes` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `LightweightBrowserCache()` |
    `LightweightBrowserCache​(BrowserCache cache)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `clear()` |
    `BrowserCache.Entry` | `get​(String key, javax.ws.rs.core.MediaType accept)` |
    `BrowserCache.Entry` | `getAny​(String key)` |
    `long` | `getByteCount()` |
    `BrowserCache` | `getInternalCache()` |
    `long` | `getMaxBytes()` |
    `BrowserCache.Entry` | `put​(String key, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,​String> headers, byte[] cached, int expires, String etag, String lastModified)` |
    `BrowserCache.Entry` | `remove​(String key, javax.ws.rs.core.MediaType type)` |
    `void` | `setInternalCache​(BrowserCache internalCache)` |
    `void` | `setMaxBytes​(long maxBytes)` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### maxBytes

          protected long maxBytes

    - #### internalCache

          protected BrowserCache internalCache

    - #### bytes

          protected AtomicLong bytes

  - ### Constructor Detail

    - #### LightweightBrowserCache

          public LightweightBrowserCache()

    - #### LightweightBrowserCache

          public LightweightBrowserCache​(BrowserCache cache)

  - ### Method Detail

    - #### getInternalCache

          public BrowserCache getInternalCache()

    - #### setInternalCache

          public void setInternalCache​(BrowserCache internalCache)

    - #### getMaxBytes

          public long getMaxBytes()

    - #### setMaxBytes

          public void setMaxBytes​(long maxBytes)

    - #### getAny

          public BrowserCache.Entry getAny​(String key)

      Specified by:
        `getAny` in interface `BrowserCache`

    - #### remove

          public BrowserCache.Entry remove​(String key,
                                           javax.ws.rs.core.MediaType type)

      Specified by:
        `remove` in interface `BrowserCache`

    - #### getByteCount

          public long getByteCount()

    - #### get

          public BrowserCache.Entry get​(String key,
                                        javax.ws.rs.core.MediaType accept)

      Specified by:
        `get` in interface `BrowserCache`

    - #### put

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

      Specified by:
        `put` in interface `BrowserCache`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `BrowserCache`