(RecordingWithDependency) async.getValue();
recording = value.getRecording();
state = CacheBodyOperationProcessState.PLAYBACK_AND_SUPPRESS;
// add the dependency to the dependency context
final DependencyContext dependencyContext =
getPipelineContext().getDependencyContext();
dependencyContext.addDependency(value.getDependency());
} else {
// We should check to see if this thread is responsible for
// updating the cached result.
final CacheEntry entry = async.getEntry();
if (entry == null) {
// Previous result wasn't cached, this thread _isn't_
// responsible for updating the cached result, so just
// forward the events as is.
state = CacheBodyOperationProcessState.NO_CACHE_FORWARD_ONLY;
} else {
final RecordingWithDependency value =
(RecordingWithDependency) async.getValue();
if (fixedExpiryMode || value == null) {
// fixed-age expiry mode or first retrieve for the key
// This thread _is_ responsible for updating the cached
// result, so record it along with forwarding the events
// to any downstream clients.
this.state =
CacheBodyOperationProcessState.RECORD_AND_FORWARD;
} else {
// auto mode
// check if the dependency is fresh or it can be
// revalidated
final DependencyContext dependencyContext =
getPipelineContext().getDependencyContext();
final Dependency dependency = value.getDependency();
Freshness freshness =
dependency.freshness(dependencyContext);
if (freshness == Freshness.REVALIDATE) {
freshness =
dependency.revalidate(dependencyContext);
}
// if the dependency is fresh, cache can play the
// content back
if (freshness == Freshness.FRESH) {
// Get the recording from the cache.
recording = value.getRecording();
this.state =
CacheBodyOperationProcessState.PLAYBACK_AND_SUPPRESS;
final SystemClock clock =
SystemClock.getDefaultInstance();
final Time currentTime = clock.getCurrentTime();
final PipelineCacheState pcs =
new PipelineCacheState(currentTime.addPeriod(
dependency.getTimeToLive()));
dependencyContext.addDependency(dependency);
// update the cache with the old value so other
// threads don't need to wait the timeout period
ProviderResult result = new ProviderResult(
value, group, true, pcs);