com.netflix.eureka.resources
Class ResponseCache

java.lang.Object
  extended by com.netflix.eureka.resources.ResponseCache

public class ResponseCache
extends java.lang.Object

The class that is responsible for caching registry information that will be queried by the clients.

The cache is maintained in compressed and non-compressed form for three categories of requests - all applications, delta changes and for individual applications. The compressed form is probably the most efficient in terms of network traffic especially when querying all applications. The cache also maintains separate pay load for JSON and XML formats and for multiple versions too. The cache is updated periodically to reflect the latest information configured by EurekaServerConfig.getResponseCacheUpdateIntervalMs().


Nested Class Summary
static class ResponseCache.Key
          The key for the cached payload.
static class ResponseCache.KeyType
           
 
Field Summary
static java.lang.String ALL_APPS
           
static java.lang.String ALL_APPS_DELTA
           
 
Method Summary
 java.lang.String get(ResponseCache.Key key)
          Get the cached information about applications.
 int getCurrentSize()
          Get the number of items in the response cache.
 byte[] getGZIP(ResponseCache.Key key)
          Get the compressed information about the applications.
static ResponseCache getInstance()
           
static java.util.concurrent.atomic.AtomicLong getVersionDelta()
          Gets the version number of the cached data.
 void invalidate(ResponseCache.Key... keys)
          Invalidate the cache information given the list of keys.
 void invalidate(java.lang.String appName)
          Invalidate the cache of a particular application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_APPS

public static final java.lang.String ALL_APPS
See Also:
Constant Field Values

ALL_APPS_DELTA

public static final java.lang.String ALL_APPS_DELTA
See Also:
Constant Field Values
Method Detail

getInstance

public static ResponseCache getInstance()

get

public java.lang.String get(ResponseCache.Key key)
Get the cached information about applications.

If the cached information is not available it is generated on the first request. After the first request, the information is then updated periodically by a background thread.

Parameters:
key - the key for which the cached information needs to be obtained.
Returns:
payload which contains information about the applications.

getGZIP

public byte[] getGZIP(ResponseCache.Key key)
Get the compressed information about the applications.

Parameters:
key - the key for which the compressed cached information needs to be obtained.
Returns:
compressed payload which contains information about the applications.

invalidate

public void invalidate(java.lang.String appName)
Invalidate the cache of a particular application.

Parameters:
appName - the application name of the application.

invalidate

public void invalidate(ResponseCache.Key... keys)
Invalidate the cache information given the list of keys.

Parameters:
keys - the list of keys for which the cache information needs to be invalidated.

getVersionDelta

public static java.util.concurrent.atomic.AtomicLong getVersionDelta()
Gets the version number of the cached data.

Returns:
teh version number of the cached data.

getCurrentSize

@Monitor(name="responseCacheSize",
         type=GAUGE)
public int getCurrentSize()
Get the number of items in the response cache.

Returns:
int value representing the number of items in response cache.