com.netflix.hystrix
Class HystrixRequestCache

java.lang.Object
  extended by com.netflix.hystrix.HystrixRequestCache

public class HystrixRequestCache
extends java.lang.Object

Cache that is scoped to the current request as managed by HystrixRequestVariableDefault.

This is used for short-lived caching of HystrixCommand instances to allow de-duping of command executions within a request.


Method Summary
 void clear(java.lang.String cacheKey)
          Clear the cache for a given cacheKey.
<T> java.util.concurrent.Future<T>
get(java.lang.String cacheKey)
          Retrieve a cached Future for this request scope if a matching command has already been executed/queued.
static HystrixRequestCache getInstance(HystrixCollapserKey key, HystrixConcurrencyStrategy concurrencyStrategy)
           
static HystrixRequestCache getInstance(HystrixCommandKey key, HystrixConcurrencyStrategy concurrencyStrategy)
           
<T> java.util.concurrent.Future<T>
putIfAbsent(java.lang.String cacheKey, java.util.concurrent.Future<T> f)
          Put the Future in the cache if it does not already exist.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HystrixRequestCache getInstance(HystrixCommandKey key,
                                              HystrixConcurrencyStrategy concurrencyStrategy)

getInstance

public static HystrixRequestCache getInstance(HystrixCollapserKey key,
                                              HystrixConcurrencyStrategy concurrencyStrategy)

get

public <T> java.util.concurrent.Future<T> get(java.lang.String cacheKey)
Retrieve a cached Future for this request scope if a matching command has already been executed/queued.

Returns:
Future<T>

putIfAbsent

public <T> java.util.concurrent.Future<T> putIfAbsent(java.lang.String cacheKey,
                                                      java.util.concurrent.Future<T> f)
Put the Future in the cache if it does not already exist.

If this method returns a non-null value then another thread won the race and it should be returned instead of proceeding with execution of the new Future.

Parameters:
cacheKey - key as defined by HystrixCommand.getCacheKey()
f - Future to be cached
Returns:
null if nothing else was in the cache (or this HystrixCommand does not have a cacheKey) or previous value if another thread beat us to adding to the cache

clear

public void clear(java.lang.String cacheKey)
Clear the cache for a given cacheKey.

Parameters:
cacheKey - key as defined by HystrixCommand.getCacheKey()