public abstract class AbstractBroadcasterCache extends java.lang.Object implements BroadcasterCache, CleanUpMemory
BroadcasterCache which is used to implement headers or query parameters or
session based caching.| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractBroadcasterCache.CachedMessage |
BroadcasterCache.STRATEGY| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
protected int |
maxCachedinMs |
protected java.util.List<AbstractBroadcasterCache.CachedMessage> |
queue |
protected java.util.concurrent.ScheduledExecutorService |
reaper |
protected java.util.concurrent.ScheduledFuture |
scheduledFuture |
BROADCASTER_CACHE_TRACKER| Constructor and Description |
|---|
AbstractBroadcasterCache() |
| Modifier and Type | Method and Description |
|---|---|
void |
addToCache(java.lang.String id,
AtmosphereResource resource,
java.lang.Object object)
Start tracking messages associated with
AtmosphereResource from the cache |
abstract void |
cache(java.lang.String id,
AtmosphereResource r,
AbstractBroadcasterCache.CachedMessage cm)
Cache the last message broadcasted.
|
void |
cleanup()
Clean up the associated
ScheduledFuture |
int |
getMaxCachedinMs()
Get the maximum time a broadcasted message can stay cached.
|
int |
getQueueDepth()
Get the number of messages which are currently in the cache.
|
java.util.List<java.lang.Object> |
retrieveFromCache(java.lang.String id,
AtmosphereResource r)
Retrieve messages associated with
AtmosphereResource |
abstract AbstractBroadcasterCache.CachedMessage |
retrieveLastMessage(java.lang.String id,
AtmosphereResource r)
Return the last message broadcasted to the
AtmosphereResource. |
void |
setExecutorService(java.util.concurrent.ScheduledExecutorService reaper)
Set the associated
ScheduledExecutorService |
void |
setMaxCachedinMs(int maxCachedinMs)
Set the maximum time a broadcasted message can stay cached.
|
void |
start()
Start
|
void |
stop()
Stop
|
protected static final org.slf4j.Logger logger
protected final java.util.List<AbstractBroadcasterCache.CachedMessage> queue
protected java.util.concurrent.ScheduledExecutorService reaper
protected int maxCachedinMs
protected java.util.concurrent.ScheduledFuture scheduledFuture
public final void start()
start in interface BroadcasterCachepublic void setExecutorService(java.util.concurrent.ScheduledExecutorService reaper)
ScheduledExecutorServicesetExecutorService in interface CleanUpMemorypublic final void stop()
stop in interface BroadcasterCachepublic void cleanup()
CleanUpMemoryScheduledFuturecleanup in interface CleanUpMemorypublic final void addToCache(java.lang.String id,
AtmosphereResource resource,
java.lang.Object object)
AtmosphereResource from the cacheaddToCache in interface BroadcasterCacheresource - AtmosphereResourceobject - a broadcasted message.public abstract void cache(java.lang.String id,
AtmosphereResource r,
AbstractBroadcasterCache.CachedMessage cm)
r - AtmosphereResource.cm - AbstractBroadcasterCache.CachedMessagepublic abstract AbstractBroadcasterCache.CachedMessage retrieveLastMessage(java.lang.String id, AtmosphereResource r)
AtmosphereResource.r - AtmosphereResource.AbstractBroadcasterCache.CachedMessage, or null if not matched.public final java.util.List<java.lang.Object> retrieveFromCache(java.lang.String id,
AtmosphereResource r)
AtmosphereResourceretrieveFromCache in interface BroadcasterCacher - AtmosphereResourceList of messages (String).public int getQueueDepth()
public int getMaxCachedinMs()
public void setMaxCachedinMs(int maxCachedinMs)
maxCachedinMs - time in millisecondsCopyright © 2018. All Rights Reserved.