Class RedisCacher
java.lang.Object
services.moleculer.service.MoleculerComponent
services.moleculer.service.Middleware
services.moleculer.cacher.Cacher
services.moleculer.cacher.DistributedCacher
services.moleculer.cacher.RedisCacher
- All Implemented Interfaces:
io.lettuce.core.event.EventBus, MetricConstants, MoleculerLifecycle
Redis-based distributed cache. Supports SSL, clustering and password
authentication. It's the one of the fastest distributed cache. Supports
global and entry-level TTL configuration.
Required dependency:
// https://mvnrepository.com/artifact/biz.paluch.redis/lettuce
compile group: 'biz.paluch.redis', name: 'lettuce', version: '4.5.0.Final'
Required dependency:
// https://mvnrepository.com/artifact/biz.paluch.redis/lettuce
compile group: 'biz.paluch.redis', name: 'lettuce', version: '4.5.0.Final'
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RedisGetSetClientprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected MetricCounterprotected ExecutorServiceprotected io.lettuce.core.SetArgsprotected Stringprotected ScheduledExecutorServiceprotected booleanprotected Serializerprotected final AtomicIntegerprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected intprotected String[]Fields 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
ConstructorsConstructorDescriptionRedisCacher(String... urls) RedisCacher(String password, int defaultTtl, boolean secure, String... urls) -
Method Summary
Modifier and TypeMethodDescriptionio.datatree.PromiseCleans this cache.protected voidconnect()io.datatree.PromiseDeletes a content from this cache.protected io.datatree.Promisereactor.core.publisher.Flux<io.lettuce.core.event.Event> get()io.datatree.PromiseGets a cached content by a key.io.datatree.PromiseLists all keys of cached entries.intgetTtl()String[]getUrls()booleanisSecure()voidpublish(io.lettuce.core.event.Event event) protected voidio.datatree.PromiseSets a content by key into the cache.voidsetPassword(String password) voidsetSecure(boolean useSSL) voidsetSerializer(Serializer serializer) voidsetTtl(int ttl) voidvoidstarted(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
-
STATUS_DISCONNECTING
protected static final int STATUS_DISCONNECTING- See Also:
-
STATUS_DISCONNECTED
protected static final int STATUS_DISCONNECTED- See Also:
-
STATUS_CONNECTING
protected static final int STATUS_CONNECTING- See Also:
-
STATUS_CONNECTED
protected static final int STATUS_CONNECTED- See Also:
-
STATUS_STOPPED
protected static final int STATUS_STOPPED- See Also:
-
status
-
password
-
ttl
protected int ttl -
secure
protected boolean secure -
urls
-
client
-
serializer
-
executor
-
scheduler
-
expiration
protected io.lettuce.core.SetArgs expiration -
counterGet
-
counterSet
-
counterDel
-
counterClean
-
counterFound
-
-
Constructor Details
-
RedisCacher
public RedisCacher() -
RedisCacher
-
RedisCacher
-
-
Method Details
-
started
Initializes cacher instance.- Specified by:
startedin interfaceMoleculerLifecycle- Overrides:
startedin classCacher- Parameters:
broker- parent ServiceBroker- Throws:
Exception
-
connect
protected void connect() -
disconnect
protected io.datatree.Promise disconnect() -
reconnect
protected void reconnect() -
stopped
public void stopped()- Specified by:
stoppedin interfaceMoleculerLifecycle- Overrides:
stoppedin classMoleculerComponent
-
get
-
set
Description copied from class:CacherSets a content by key into the cache. -
del
-
clean
-
getCacheKeys
public io.datatree.Promise getCacheKeys()Lists all keys of cached entries.- Specified by:
getCacheKeysin classCacher- Returns:
- a Tree object with a "keys" array.
-
publish
public void publish(io.lettuce.core.event.Event event) - Specified by:
publishin interfaceio.lettuce.core.event.EventBus
-
get
public reactor.core.publisher.Flux<io.lettuce.core.event.Event> get()- Specified by:
getin interfaceio.lettuce.core.event.EventBus
-
getUrls
-
setUrls
-
getPassword
-
setPassword
-
isSecure
public boolean isSecure() -
setSecure
public void setSecure(boolean useSSL) -
getTtl
public int getTtl() -
setTtl
public void setTtl(int ttl) -
getSerializer
-
setSerializer
-