public class MemoryCacher extends Cacher implements java.lang.Runnable
RedisCacher,
OHCacher| Modifier and Type | Class and Description |
|---|---|
protected static class |
MemoryCacher.MemoryPartition |
protected static class |
MemoryCacher.PartitionEntry |
| Modifier and Type | Field and Description |
|---|---|
protected int |
capacity
Maximum number of entries per partition
|
protected int |
cleanup
Cleanup period time, in SECONDS (0 = disable cleanup process)
|
protected java.util.HashMap<java.lang.String,MemoryCacher.MemoryPartition> |
partitions |
protected java.util.concurrent.locks.Lock |
readLock |
protected java.util.concurrent.ScheduledFuture<?> |
timer
Cancelable timer
|
protected int |
ttl
Expire time, in SECONDS (0 = never expires)
|
protected java.util.concurrent.locks.Lock |
writeLock |
broker, logger, name| Constructor and Description |
|---|
MemoryCacher() |
MemoryCacher(int capacityPerPartition,
int defaultTtl) |
MemoryCacher(int capacityPerPartition,
int defaultTtl,
int cleanupSeconds) |
| Modifier and Type | Method and Description |
|---|---|
io.datatree.Promise |
clean(java.lang.String match)
Cleans this cache.
|
io.datatree.Promise |
del(java.lang.String key)
Deletes a content from this cache.
|
io.datatree.Promise |
get(java.lang.String key)
Gets a cached content by a key.
|
int |
getCapacity() |
int |
getCleanup() |
int |
getTtl() |
protected static int |
partitionPosition(java.lang.String key,
boolean throwErrorIfMissing) |
void |
run() |
io.datatree.Promise |
set(java.lang.String key,
io.datatree.Tree value,
int ttl)
Sets a content by key into the cache.
|
void |
setCapacity(int capacity) |
void |
setCleanup(int cleanup) |
void |
setTtl(int ttl) |
void |
started(ServiceBroker broker)
Initializes cacher instance.
|
void |
stopped() |
appendToKey, appendTree, getCacheKey, install, serializeKeygetBroker, getLogger, getNameprotected int capacity
protected int ttl
protected int cleanup
protected final java.util.concurrent.locks.Lock readLock
protected final java.util.concurrent.locks.Lock writeLock
protected final java.util.HashMap<java.lang.String,MemoryCacher.MemoryPartition> partitions
protected volatile java.util.concurrent.ScheduledFuture<?> timer
public MemoryCacher()
public MemoryCacher(int capacityPerPartition,
int defaultTtl)
public MemoryCacher(int capacityPerPartition,
int defaultTtl,
int cleanupSeconds)
public void started(ServiceBroker broker) throws java.lang.Exception
started in class MoleculerComponentbroker - parent ServiceBrokerjava.lang.Exceptionpublic void run()
run in interface java.lang.Runnablepublic void stopped()
stopped in class MoleculerComponentpublic io.datatree.Promise get(java.lang.String key)
Cacherpublic io.datatree.Promise set(java.lang.String key,
io.datatree.Tree value,
int ttl)
Cacherpublic io.datatree.Promise del(java.lang.String key)
Cacherpublic io.datatree.Promise clean(java.lang.String match)
Cacherprotected static final int partitionPosition(java.lang.String key,
boolean throwErrorIfMissing)
public int getCapacity()
public void setCapacity(int capacity)
public int getTtl()
public void setTtl(int ttl)
public int getCleanup()
public void setCleanup(int cleanup)