Top Description Inners Fields Constructors Methods
reactor.core.publisher

pack-priv Class MonoCacheTime<T>

extends InternalMonoOperator<T, T>
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.time.Duration, java.util.Objects, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicReferenceFieldUpdater, java.util.function.Function, .Supplier, org.reactivestreams.Subscription, reactor.core.CoreSubscriber, .Exceptions, reactor.core.scheduler.Scheduler, .Schedulers, reactor.util.Logger, .Loggers, reactor.util.annotation.Nullable, reactor.util.context.Context, .ContextView

An operator that caches the value from a source Mono with a TTL, after which the value expires and the next subscription will trigger a new source subscription.
Author
Simon Baslé

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv final Scheduler
private static final Duration
pack-priv static final Signal<?>
private static final Logger
pack-priv volatile Signal<T>
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime<T>, Signal<T>>
pack-priv final Function<? super Signal<T>, Duration>
Inherited from reactor.core.publisher.InternalMonoOperator:
optimizableOperator

Constructor Summary

AccessConstructor and Description
pack-priv
MonoCacheTime(Mono<? extends T> source, Duration ttl, Scheduler clock)

pack-priv
MonoCacheTime(Mono<? extends T> source)

pack-priv
MonoCacheTime(Mono<? extends T> source, Function<? super Signal<T>, Duration> ttlGenerator, Scheduler clock)

pack-priv
MonoCacheTime(Mono<? extends T> source, Function<? super T, Duration> valueTtlGenerator, Function<Throwable, Duration> errorTtlGenerator, Supplier<Duration> emptyTtlGenerator, Scheduler clock)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Overrides reactor.core.publisher.InternalMonoOperator.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
public CoreSubscriber<? super T>
subscribeOrReturn(CoreSubscriber<? super T> actual)

Implements abstract reactor.core.publisher.InternalMonoOperator.subscribeOrReturn.

Implements reactor.core.publisher.OptimizableOperator.subscribeOrReturn.

Allow delegation of the subscription by returning a CoreSubscriber, or force subscription encapsulation by returning null.
Inherited from reactor.core.publisher.InternalMonoOperator:
nextOptimizableSourcesourcesubscribe

Field Detail

clockback to summary
pack-priv final Scheduler clock
DURATION_INFINITEback to summary
private static final Duration DURATION_INFINITE
EMPTYback to summary
pack-priv static final Signal<?> EMPTY
LOGGERback to summary
private static final Logger LOGGER
stateback to summary
pack-priv volatile Signal<T> state
STATEback to summary
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime<T>, Signal<T>> STATE
ttlGeneratorback to summary
pack-priv final Function<? super Signal<T>, Duration> ttlGenerator

Constructor Detail

MonoCacheTimeback to summary
pack-priv MonoCacheTime(Mono<? extends T> source, Duration ttl, Scheduler clock)
MonoCacheTimeback to summary
pack-priv MonoCacheTime(Mono<? extends T> source)
MonoCacheTimeback to summary
pack-priv MonoCacheTime(Mono<? extends T> source, Function<? super Signal<T>, Duration> ttlGenerator, Scheduler clock)
MonoCacheTimeback to summary
pack-priv MonoCacheTime(Mono<? extends T> source, Function<? super T, Duration> valueTtlGenerator, Function<Throwable, Duration> errorTtlGenerator, Supplier<Duration> emptyTtlGenerator, Scheduler clock)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Overrides reactor.core.publisher.InternalMonoOperator.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
subscribeOrReturnback to summary
public CoreSubscriber<? super T> subscribeOrReturn(CoreSubscriber<? super T> actual)

Implements abstract reactor.core.publisher.InternalMonoOperator.subscribeOrReturn.

Implements reactor.core.publisher.OptimizableOperator.subscribeOrReturn.

Doc from reactor.core.publisher.OptimizableOperator.subscribeOrReturn.

Allow delegation of the subscription by returning a CoreSubscriber, or force subscription encapsulation by returning null. This can be used in conjunction with nextOptimizableSource() to perform subscription in a loop instead of by recursion.

Returns:CoreSubscriber<? super T>

next CoreSubscriber or "null" if the subscription was already done inside the method

Annotations
@Override
reactor.core.publisher back to summary

pack-priv final Class MonoCacheTime.CacheMonoSubscriber<T>

extends Operators.MonoSubscriber<T, T>
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv MonoCacheTime.CoordinatorSubscriber<T>
Inherited from reactor.core.publisher.Operators.MonoSubscriber:
actualCANCELLEDHAS_REQUEST_HAS_VALUEHAS_REQUEST_NO_VALUENO_REQUEST_HAS_VALUENO_REQUEST_NO_VALUEstateSTATEvalue

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
cancel()

Overrides reactor.core.publisher.Operators.MonoSubscriber.cancel.

Implements org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Overrides reactor.core.publisher.Operators.MonoSubscriber.scanUnsafe.

Overrides default reactor.core.publisher.InnerProducer.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
Inherited from reactor.core.publisher.Operators.MonoSubscriber:
actualclearcompletediscardisCancelledisEmptyonCompleteonErroronNextonSubscribepollrequestrequestFusionsetValuesize

Field Detail

coordinatorback to summary
pack-priv MonoCacheTime.CoordinatorSubscriber<T> coordinator

Constructor Detail

CacheMonoSubscriberback to summary
pack-priv CacheMonoSubscriber(CoreSubscriber<? super T> actual)

Method Detail

cancelback to summary
public void cancel()

Overrides reactor.core.publisher.Operators.MonoSubscriber.cancel.

Implements org.reactivestreams.Subscription.cancel.

Doc from org.reactivestreams.Subscription.cancel.

Request the Publisher to stop sending data and clean up resources.

Data may still be sent to meet previously signalled demand after calling cancel.

Annotations
@Override
scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Overrides reactor.core.publisher.Operators.MonoSubscriber.scanUnsafe.

Overrides default reactor.core.publisher.InnerProducer.scanUnsafe.

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Override
reactor.core.publisher back to summary

pack-priv final Class MonoCacheTime.CoordinatorSubscriber<T>

extends Object
implements InnerConsumer<T>, Signal<T>
Class Inheritance
All Implemented Interfaces
reactor.core.publisher.Signal, java.util.function.Consumer, java.util.function.Supplier, reactor.core.publisher.InnerConsumer, reactor.core.Scannable, reactor.core.CoreSubscriber, org.reactivestreams.Subscriber

Field Summary

Modifier and TypeField and Description
private static final Operators.MonoSubscriber<I, O>[]
pack-priv final MonoCacheTime<T>
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime.CoordinatorSubscriber<T>, Subscription>
S

pack-priv volatile Operators.MonoSubscriber<T, T>[]
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime.CoordinatorSubscriber<T>, Operators.MonoSubscriber<I, O>[]>
pack-priv volatile Subscription
private static final Operators.MonoSubscriber<I, O>[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final boolean
public Context
currentContext()

Overrides default reactor.core.CoreSubscriber.currentContext.

Request a Context from dependent components which can include downstream operators during subscribing or a terminal org.reactivestreams.Subscriber.
public T
get()

Implements reactor.core.publisher.Signal.get.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.
public ContextView
getContextView()

Implements reactor.core.publisher.Signal.getContextView.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.
public Subscription
getSubscription()

Implements reactor.core.publisher.Signal.getSubscription.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.
public Throwable
getThrowable()

Implements reactor.core.publisher.Signal.getThrowable.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.
public SignalType
getType()

Implements reactor.core.publisher.Signal.getType.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.
public void
onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Successful terminal state.
public void
onError(Throwable
the throwable signaled
t
)

Implements org.reactivestreams.Subscriber.onError.

Failed terminal state.
public void
onNext(T
the element signaled
t
)

Implements org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).
public void
onSubscribe(Subscription
the Subscription that allows requesting data via Subscription#request(long)
s
)

Implements reactor.core.CoreSubscriber.onSubscribe.

Implementors should initialize any state used by onNext(Object) before calling Subscription#request(long).
pack-priv final void
public Object
scanUnsafe(Scannable.Attr<T>
a Attr to resolve for the component.
key
)

Implements reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place.
private void
signalCached(Signal<T> signal)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTYback to summary
private static final Operators.MonoSubscriber<I, O>[] EMPTY
mainback to summary
pack-priv final MonoCacheTime<T> main
Sback to summary
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime.CoordinatorSubscriber<T>, Subscription> S
subscribersback to summary
pack-priv volatile Operators.MonoSubscriber<T, T>[] subscribers
SUBSCRIBERSback to summary
pack-priv static final AtomicReferenceFieldUpdater<MonoCacheTime.CoordinatorSubscriber<T>, Operators.MonoSubscriber<I, O>[]> SUBSCRIBERS
subscriptionback to summary
pack-priv volatile Subscription subscription
TERMINATEDback to summary
private static final Operators.MonoSubscriber<I, O>[] TERMINATED

Constructor Detail

CoordinatorSubscriberback to summary
pack-priv CoordinatorSubscriber(MonoCacheTime<T> main)
Annotations
@SuppressWarnings:unchecked

Method Detail

addback to summary
pack-priv final boolean add(Operators.MonoSubscriber<T, T> toAdd)
currentContextback to summary
public Context currentContext()

Overrides default reactor.core.CoreSubscriber.currentContext.

Doc from reactor.core.CoreSubscriber.currentContext.

Request a Context from dependent components which can include downstream operators during subscribing or a terminal org.reactivestreams.Subscriber.

Returns:Context

a resolved context or Context#empty()

Annotations
@Override
getback to summary
public T get()

Implements reactor.core.publisher.Signal.get.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.

Returns:T

Doc from reactor.core.publisher.Signal.get.

the item associated with this (onNext) signal, or null if not relevant

Annotations
@Override
getContextViewback to summary
public ContextView getContextView()

Implements reactor.core.publisher.Signal.getContextView.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.

Returns:ContextView

Doc from reactor.core.publisher.Signal.getContextView.

a readonly ContextView, or an empty one if no context is available.

Annotations
@Override
getSubscriptionback to summary
public Subscription getSubscription()

Implements reactor.core.publisher.Signal.getSubscription.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.

Returns:Subscription

Doc from reactor.core.publisher.Signal.getSubscription.

the Subscription associated with this (onSubscribe) signal, or null if not relevant

Annotations
@Override
getThrowableback to summary
public Throwable getThrowable()

Implements reactor.core.publisher.Signal.getThrowable.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.

Returns:Throwable

Doc from reactor.core.publisher.Signal.getThrowable.

the Throwable associated with this (onError) signal, or null if not relevant

Annotations
@Override
getTypeback to summary
public SignalType getType()

Implements reactor.core.publisher.Signal.getType.

unused in this context as the Signal interface is only implemented for use in the main's STATE compareAndSet.

Returns:SignalType

Doc from reactor.core.publisher.Signal.getType.

the type of the signal

Annotations
@Override
onCompleteback to summary
public void onComplete()

Implements org.reactivestreams.Subscriber.onComplete.

Doc from org.reactivestreams.Subscriber.onComplete.

Successful terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Annotations
@Override
onErrorback to summary
public void onError(Throwable t)

Implements org.reactivestreams.Subscriber.onError.

Doc from org.reactivestreams.Subscriber.onError.

Failed terminal state.

No further events will be sent even if Subscription#request(long) is invoked again.

Parameters
t:Throwable

the throwable signaled

Annotations
@Override
onNextback to summary
public void onNext(T t)

Implements org.reactivestreams.Subscriber.onNext.

Doc from org.reactivestreams.Subscriber.onNext.

Data notification sent by the Publisher in response to requests to Subscription#request(long).

Parameters
t:T

the element signaled

Annotations
@Override
onSubscribeback to summary
public void onSubscribe(Subscription s)

Implements reactor.core.CoreSubscriber.onSubscribe.

Doc from reactor.core.CoreSubscriber.onSubscribe.

Implementors should initialize any state used by onNext(Object) before calling Subscription#request(long). Should further onNext related state modification occur, thread-safety will be required.

Note that an invalid request <= 0 will not produce an onError and will simply be ignored or reported through a debug-enabled reactor.util.Logger. Invoked after calling Publisher#subscribe(Subscriber).

No data will start flowing until Subscription#request(long) is invoked.

It is the responsibility of this Subscriber instance to call Subscription#request(long) whenever more data is wanted.

The Publisher will send notifications only in response to Subscription#request(long).

Parameters
s:Subscription

Doc from org.reactivestreams.Subscriber.onSubscribe.

the Subscription that allows requesting data via Subscription#request(long)

Annotations
@Override
removeback to summary
pack-priv final void remove(Operators.MonoSubscriber<T, T> toRemove)
scanUnsafeback to summary
public Object scanUnsafe(Scannable.Attr<T> key)

Implements reactor.core.Scannable.scanUnsafe.

Doc from reactor.core.Scannable.scanUnsafe.

This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return null if no specific value is available.

For public consumption of attributes, prefer using scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.

Parameters
key:Scannable.Attr<T>

a Attr to resolve for the component.

Returns:Object

the value associated to the key for that specific component, or null if none.

Annotations
@Nullable
@Override
signalCachedback to summary
private void signalCached(Signal<T> signal)
Annotations
@SuppressWarnings:unchecked