org.jboss.resteasy.client.cache
Class LightweightBrowserCache

java.lang.Object
  extended by org.jboss.resteasy.client.cache.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 $
Author:
Bill Burke

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.resteasy.client.cache.BrowserCache
BrowserCache.Entry, BrowserCache.Header
 
Field Summary
protected  java.util.concurrent.atomic.AtomicLong bytes
           
protected  BrowserCache internalCache
           
protected  long maxBytes
           
 
Constructor Summary
LightweightBrowserCache()
           
LightweightBrowserCache(BrowserCache cache)
           
 
Method Summary
 void clear()
           
 BrowserCache.Entry get(java.lang.String key, MediaType accept)
           
 BrowserCache.Entry getAny(java.lang.String key)
           
 long getByteCount()
           
 BrowserCache getInternalCache()
           
 long getMaxBytes()
           
 BrowserCache.Entry put(java.lang.String key, MediaType mediaType, MultivaluedMap<java.lang.String,java.lang.String> headers, byte[] cached, int expires, java.lang.String etag, java.lang.String lastModified)
           
 BrowserCache.Entry remove(java.lang.String key, 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 java.util.concurrent.atomic.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(java.lang.String key)
Specified by:
getAny in interface BrowserCache

remove

public BrowserCache.Entry remove(java.lang.String key,
                                 MediaType type)
Specified by:
remove in interface BrowserCache

getByteCount

public long getByteCount()

get

public BrowserCache.Entry get(java.lang.String key,
                              MediaType accept)
Specified by:
get in interface BrowserCache

put

public BrowserCache.Entry put(java.lang.String key,
                              MediaType mediaType,
                              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

clear

public void clear()
Specified by:
clear in interface BrowserCache


Copyright © 2009. All Rights Reserved.