Class JCacheCacher
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.service.Middleware
services.moleculer.cacher.Cacher
services.moleculer.cacher.DistributedCacher
services.moleculer.cacher.JCacheCacher
- All Implemented Interfaces:
MetricConstants, MoleculerLifecycle
JSR-107 JCache is a standardized caching API that is Java 6 compatible and
introduced in JEE 8. WARNING! Core JCache API does NOT support entry-level
TTL parameter! If you need this feature use
// https://mvnrepository.com/artifact/javax.cache/cache-api
compile group: 'javax.cache', name: 'cache-api', version: '1.1.1'
RedisCacher or
MemoryCacher. JCache is implemented by various
caching solutions:
- Apache Ignite
- Hazelcast
- Oracle Coherence
- Couchbase (https://github.com/couchbaselabs/couchbase-java-cache)
- Terracotta Ehcache
- Infinispan
- Blazing Cache
- Cache2k
- Caffeine
- WebSphere eXtreme Scale
// https://mvnrepository.com/artifact/javax.cache/cache-api
compile group: 'javax.cache', name: 'cache-api', version: '1.1.1'
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionOptional cache configurations by cache regionsprotected javax.cache.CacheManagerprotected booleanClose empty cachesprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected javax.cache.configuration.Configuration<String, byte[]> Default cache cconfigurationprotected final ReentrantReadWriteLock.ReadLockprotected Serializerprotected final ReentrantReadWriteLock.WriteLockFields inherited from class DistributedCacher
CONTENT, hashers, maxParamsLengthFields inherited from class MoleculerComponent
broker, logger, nameFields inherited from interface MetricConstants
MOLECULER_CACHER_CLEAN_TIME, MOLECULER_CACHER_CLEAN_TIME_DESC, MOLECULER_CACHER_CLEAN_TOTAL, MOLECULER_CACHER_CLEAN_TOTAL_DESC, MOLECULER_CACHER_DEL_TIME, MOLECULER_CACHER_DEL_TIME_DESC, MOLECULER_CACHER_DEL_TOTAL, MOLECULER_CACHER_DEL_TOTAL_DESC, MOLECULER_CACHER_EXPIRED_TOTAL, MOLECULER_CACHER_EXPIRED_TOTAL_DESC, MOLECULER_CACHER_FOUND_TOTAL, MOLECULER_CACHER_FOUND_TOTAL_DESC, MOLECULER_CACHER_GET_TIME, MOLECULER_CACHER_GET_TIME_DESC, MOLECULER_CACHER_GET_TOTAL, MOLECULER_CACHER_GET_TOTAL_DESC, MOLECULER_CACHER_SET_TIME, MOLECULER_CACHER_SET_TIME_DESC, MOLECULER_CACHER_SET_TOTAL, MOLECULER_CACHER_SET_TOTAL_DESC, MOLECULER_CIRCUIT_BREAKER_HALF_OPENED_ACTIVE, MOLECULER_CIRCUIT_BREAKER_HALF_OPENED_ACTIVE_DESC, MOLECULER_CIRCUIT_BREAKER_OPENED_ACTIVE, MOLECULER_CIRCUIT_BREAKER_OPENED_ACTIVE_DESC, MOLECULER_CIRCUIT_BREAKER_OPENED_TOTAL, MOLECULER_CIRCUIT_BREAKER_OPENED_TOTAL_DESC, MOLECULER_EVENT_BROADCAST_TOTAL, MOLECULER_EVENT_BROADCAST_TOTAL_DESC, MOLECULER_EVENT_BROADCASTLOCAL_TOTAL, MOLECULER_EVENT_BROADCASTLOCAL_TOTAL_DESC, MOLECULER_EVENT_EMIT_TOTAL, MOLECULER_EVENT_EMIT_TOTAL_DESC, MOLECULER_EVENT_RECEIVED_ACTIVE, MOLECULER_EVENT_RECEIVED_ACTIVE_DESC, MOLECULER_EVENT_RECEIVED_ERROR_TOTAL, MOLECULER_EVENT_RECEIVED_ERROR_TOTAL_DESC, MOLECULER_EVENT_RECEIVED_TIME, MOLECULER_EVENT_RECEIVED_TIME_DESC, MOLECULER_EVENT_RECEIVED_TOTAL, MOLECULER_EVENT_RECEIVED_TOTAL_DESC, MOLECULER_EXECUTOR, MOLECULER_REQUEST_ACTIVE, MOLECULER_REQUEST_ACTIVE_DESC, MOLECULER_REQUEST_ERROR_TOTAL, MOLECULER_REQUEST_ERROR_TOTAL_DESC, MOLECULER_REQUEST_LEVELS, MOLECULER_REQUEST_LEVELS_DESC, MOLECULER_REQUEST_RETRY_ATTEMPTS_TOTAL, MOLECULER_REQUEST_RETRY_ATTEMPTS_TOTAL_DESC, MOLECULER_REQUEST_TIME, MOLECULER_REQUEST_TIME_DESC, MOLECULER_REQUEST_TIMEOUT_TOTAL, MOLECULER_REQUEST_TIMEOUT_TOTAL_DESC, MOLECULER_REQUEST_TOTAL, MOLECULER_REQUEST_TOTAL_DESC, MOLECULER_SCHEDULER, MOLECULER_TRANSIT_CONNECTED, MOLECULER_TRANSIT_CONNECTED_DESC, MOLECULER_TRANSIT_ORPHAN_RESPONSE_TOTAL, MOLECULER_TRANSIT_ORPHAN_RESPONSE_TOTAL_DESC, MOLECULER_TRANSIT_REQUESTS_ACTIVE, MOLECULER_TRANSIT_REQUESTS_ACTIVE_DESC, MOLECULER_TRANSIT_STREAMS_RECEIVE_ACTIVE, MOLECULER_TRANSIT_STREAMS_RECEIVE_ACTIVE_DESC, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_BYTES, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_BYTES_DESC, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_TOTAL, MOLECULER_TRANSPORTER_PACKETS_RECEIVED_TOTAL_DESC, MOLECULER_TRANSPORTER_PACKETS_SENT_BYTES, MOLECULER_TRANSPORTER_PACKETS_SENT_BYTES_DESC, MOLECULER_TRANSPORTER_PACKETS_SENT_TOTAL, MOLECULER_TRANSPORTER_PACKETS_SENT_TOTAL_DESC -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCacheConfiguration(String partition, javax.cache.configuration.Configuration<String, byte[]> configuration) io.datatree.PromiseCleans this cache.protected static final longio.datatree.PromiseDeletes a content from this cache.io.datatree.PromiseGets a cached content by a key.io.datatree.PromiseLists all keys of cached entries.javax.cache.CacheManagerjavax.cache.configuration.Configuration<String, byte[]> protected javax.cache.Cache<String, byte[]> getPartition(String prefix) booleanprotected intpartitionPosition(String key, boolean throwErrorIfMissing) voidremoveCacheConfiguration(String partition) io.datatree.PromiseSets a content by key into the cache.voidsetCacheConfigurations(Map<String, javax.cache.configuration.Configuration<String, byte[]>> cacheConfigurations) voidsetCacheManager(javax.cache.CacheManager cacheManager) voidsetCloseEmptyPartitions(boolean closeEmptyCaches) voidsetDefaultConfiguration(javax.cache.configuration.Configuration<String, byte[]> defaultConfiguration) voidstarted(ServiceBroker broker) Initializes cacher instance.voidstopped()Methods inherited from class DistributedCacher
getCacheKey, getMaxParamsLength, setMaxParamsLengthMethods inherited from class Cacher
appendToKey, appendTree, install, isCachingDisabledByTheContext, isDebug, logClean, serializeKey, setDebugMethods inherited from class MoleculerComponent
getBroker, getLogger, getName
-
Field Details
-
partitions
-
cacheManager
protected javax.cache.CacheManager cacheManager -
serializer
-
closeEmptyPartitions
protected boolean closeEmptyPartitionsClose empty caches -
defaultConfiguration
Default cache cconfiguration -
cacheConfigurations
-
readLock
-
writeLock
-
counterGet
-
counterSet
-
counterDel
-
counterClean
-
counterFound
-
-
Constructor Details
-
JCacheCacher
public JCacheCacher() -
JCacheCacher
-
JCacheCacher
public JCacheCacher(javax.cache.CacheManager cacheManager)
-
-
Method Details
-
started
Initializes cacher instance.- Specified by:
startedin interfaceMoleculerLifecycle- Overrides:
startedin classCacher- Parameters:
broker- parent ServiceBroker- Throws:
Exception
-
stopped
public void stopped()- Specified by:
stoppedin interfaceMoleculerLifecycle- Overrides:
stoppedin classMoleculerComponent
-
get
-
getPartition
-
set
Description copied from class:CacherSets a content by key into the cache. -
del
-
clean
-
clean
-
partitionPosition
-
getCacheKeys
public io.datatree.Promise getCacheKeys()Lists all keys of cached entries.- Specified by:
getCacheKeysin classCacher- Returns:
- a Tree object with a "keys" array.
-
addCacheConfiguration
-
removeCacheConfiguration
-
getCacheManager
public javax.cache.CacheManager getCacheManager() -
setCacheManager
public void setCacheManager(javax.cache.CacheManager cacheManager) -
isCloseEmptyPartitions
public boolean isCloseEmptyPartitions() -
setCloseEmptyPartitions
public void setCloseEmptyPartitions(boolean closeEmptyCaches) -
getDefaultConfiguration
-
setDefaultConfiguration
public void setDefaultConfiguration(javax.cache.configuration.Configuration<String, byte[]> defaultConfiguration) -
getCacheConfigurations
-
setCacheConfigurations
-