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 AtomicLongbytesprotected BrowserCacheinternalCacheprotected longmaxBytes
-
Constructor Summary
Constructors Constructor Description LightweightBrowserCache()LightweightBrowserCache(BrowserCache cache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()BrowserCache.Entryget(String key, javax.ws.rs.core.MediaType accept)BrowserCache.EntrygetAny(String key)longgetByteCount()BrowserCachegetInternalCache()longgetMaxBytes()BrowserCache.Entryput(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.Entryremove(String key, javax.ws.rs.core.MediaType type)voidsetInternalCache(BrowserCache internalCache)voidsetMaxBytes(long maxBytes)
-
-
-
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:
getAnyin interfaceBrowserCache
-
remove
public BrowserCache.Entry remove(String key, javax.ws.rs.core.MediaType type)
- Specified by:
removein interfaceBrowserCache
-
getByteCount
public long getByteCount()
-
get
public BrowserCache.Entry get(String key, javax.ws.rs.core.MediaType accept)
- Specified by:
getin interfaceBrowserCache
-
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:
putin interfaceBrowserCache
-
clear
public void clear()
- Specified by:
clearin interfaceBrowserCache
-
-