|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xlightweb.CacheHandler
public final class CacheHandler
Cache handler Example:
RequestHandlerChain chain = new RequestHandlerChain(); chain.addLast(new CacheHandler(500)); // add a cache handler with max size 500 KB chain.addLast(new FileServiceRequestHandler(basepath)); HttpServer server = new HttpServer(chain); //...HttpClient will add a cache handler automaically, if the cacheMaxSizeKB is set larger than 0
Field Summary |
---|
Fields inherited from interface org.xlightweb.IHttpRequestHandler |
---|
DEFAULT_EXECUTION_MODE, DEFAULT_INVOKE_ON_MODE, DEFAULT_SYNCHRONIZED_ON_MODE |
Constructor Summary | |
---|---|
CacheHandler(int maxSizeByteKB)
constructor |
Method Summary | |
---|---|
List<String> |
getCacheInfo()
return the cache info |
int |
getCountCacheHit()
returns the number of cache hits |
int |
getCountCacheMiss()
returns the number of cache misses |
int |
getCurrentCacheSizeBytes()
return the current cache size |
double |
getCurrentHitRatio()
returns the current hit ratio |
int |
getMaxCacheSizeKB()
return the max cache size |
boolean |
isSharedCache()
returns true, if cache is shared |
void |
onDestroy()
|
void |
onInit()
|
void |
onRequest(IHttpExchange exchange)
call back method, which will be called if a request message (header) is received |
void |
setMaxCacheSizeKB(int sizeByteKB)
set the max cache size |
void |
setSharedCache(boolean isSharedCache)
set true, if cache is shared |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CacheHandler(int maxSizeByteKB)
maxSizeKB
- the max cache sizeMethod Detail |
---|
public void onInit()
onInit
in interface ILifeCycle
public void onDestroy() throws IOException
onDestroy
in interface ILifeCycle
IOException
public void setSharedCache(boolean isSharedCache)
isSharedCache
- true, if cache is sharedpublic boolean isSharedCache()
public void setMaxCacheSizeKB(int sizeByteKB)
sizeBytes
- the max cache sizepublic int getMaxCacheSizeKB()
public int getCurrentCacheSizeBytes()
public int getCountCacheHit()
public double getCurrentHitRatio()
public int getCountCacheMiss()
public List<String> getCacheInfo()
public void onRequest(IHttpExchange exchange) throws IOException
onRequest
in interface IHttpRequestHandler
exchange
- the exchange contains the request from the client is used to send the response
IOException
- if an exception occurred. By throwing this exception an error http response message
will be sent by xSocket, if one or more requests are unanswered. The underlying
connection will be closed
BadMessageException
- By throwing this exception an error http response message will be sent by xSocket,
which contains the exception message. The underlying connection will be closed
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |