Package jetbrains.buildServer.util
Class UptodateValue<T>
- java.lang.Object
-
- jetbrains.buildServer.util.UptodateValue<T>
-
public class UptodateValue<T> extends Object
This class operates as a time-based cache for a calculable value.- Author:
- Pavel.Sher Date: 23.09.2008
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
UptodateValue.TimeToLiveProvider<T>
static interface
UptodateValue.UpdateCallback<T>
static interface
UptodateValue.ValueProvider<T>
-
Constructor Summary
Constructors Constructor Description UptodateValue(long timeToLiveMillis)
This form is supposed to be used withfetchValue(ValueProvider)
methodUptodateValue(UptodateValue.ValueProvider<T> provider, long timeToLiveMillis)
The default form that suits most of the casesUptodateValue(UptodateValue.ValueProvider<T> provider, long ttl, TimeService timeService)
Allows to use customTimeService
UptodateValue(UptodateValue.ValueProvider<T> provider, long timeToLiveMillis, TimeService timeService, UptodateValue.UpdateCallback<T> onUpdate)
This form adds the callback to be called when the value gets updated.UptodateValue(UptodateValue.ValueProvider<T> provider, long timeToLiveMillis, UptodateValue.UpdateCallback<T> onUpdate)
This form adds the callback to be called when the value gets updated.UptodateValue(UptodateValue.ValueProvider<T> provider, UptodateValue.TimeToLiveProvider<T> ttlProvider, TimeService timeService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
fetchValue(UptodateValue.ValueProvider<T> explicitProvider)
T
getValue()
void
reset()
-
-
-
Constructor Detail
-
UptodateValue
public UptodateValue(long timeToLiveMillis)
This form is supposed to be used withfetchValue(ValueProvider)
method- Parameters:
timeToLiveMillis
- TTL of cached value in milliseconds- Since:
- 10.0
-
UptodateValue
public UptodateValue(@NotNull UptodateValue.ValueProvider<T> provider, long timeToLiveMillis)
The default form that suits most of the cases- Parameters:
provider
-UptodateValue.ValueProvider
providing new valuestimeToLiveMillis
- TTL of cached value in milliseconds
-
UptodateValue
public UptodateValue(@NotNull UptodateValue.ValueProvider<T> provider, long timeToLiveMillis, @NotNull UptodateValue.UpdateCallback<T> onUpdate)
This form adds the callback to be called when the value gets updated. The callback is only called when the value has actually changed according to Object.equals- Parameters:
provider
-UptodateValue.ValueProvider
providing new valuestimeToLiveMillis
- ttl Value TTL in millisecondsonUpdate
- callback to be called when value gets updated- Since:
- 2019.2.1
-
UptodateValue
public UptodateValue(@NotNull UptodateValue.ValueProvider<T> provider, long timeToLiveMillis, @NotNull TimeService timeService, @NotNull UptodateValue.UpdateCallback<T> onUpdate)
This form adds the callback to be called when the value gets updated. The callback is only called when the value has actually changed according to Object.equals Also supports custom TimeService- Parameters:
provider
-UptodateValue.ValueProvider
providing new valuestimeToLiveMillis
- ttl Value TTL in millisecondsonUpdate
- callback to be called when value gets updated- Since:
- 2020.2
-
UptodateValue
public UptodateValue(UptodateValue.ValueProvider<T> provider, long ttl, TimeService timeService)
Allows to use customTimeService
- Parameters:
provider
-UptodateValue.ValueProvider
providing new valuesttl
- TTL of cached value in millisecondstimeService
- customTimeService
-
UptodateValue
@TestOnly public UptodateValue(UptodateValue.ValueProvider<T> provider, @NotNull UptodateValue.TimeToLiveProvider<T> ttlProvider, TimeService timeService)
-
-
Method Detail
-
getValue
public T getValue()
-
fetchValue
public T fetchValue(UptodateValue.ValueProvider<T> explicitProvider)
- Parameters:
explicitProvider
- value provider- Returns:
- cached or updated value; data update occurs using explicitProvider
- Since:
- 10.0
-
reset
public void reset()
-
-