public class CacheRequestHandler extends BaseDataRequestHandler
It also wraps the response processor so that valid, non-partial JSON responses are cached
| Modifier and Type | Field and Description |
|---|---|
static com.codahale.metrics.Meter |
CACHE_HITS |
static com.codahale.metrics.Meter |
CACHE_MISSES |
static com.codahale.metrics.Meter |
CACHE_REQUESTS |
protected DataCache<String> |
dataCache |
protected DataRequestHandler |
next |
mapper, writer| Constructor and Description |
|---|
CacheRequestHandler(DataRequestHandler next,
DataCache<?> dataCache,
com.fasterxml.jackson.databind.ObjectMapper mapper)
Build a Cache request handler.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
getKey(DruidAggregationQuery<?> druidQuery)
Construct the cache key.
|
boolean |
handleRequest(RequestContext context,
DataApiRequest request,
DruidAggregationQuery<?> druidQuery,
ResponseProcessor response)
Handle the response, passing the request down the chain as necessary.
|
public static final com.codahale.metrics.Meter CACHE_HITS
public static final com.codahale.metrics.Meter CACHE_MISSES
public static final com.codahale.metrics.Meter CACHE_REQUESTS
@NotNull protected final DataRequestHandler next
public CacheRequestHandler(DataRequestHandler next, @NotNull DataCache<?> dataCache, com.fasterxml.jackson.databind.ObjectMapper mapper)
next - The next handler in the chaindataCache - The cache instancemapper - The mapper for all JSON processingpublic boolean handleRequest(RequestContext context, DataApiRequest request, DruidAggregationQuery<?> druidQuery, ResponseProcessor response)
DataRequestHandlercontext - The context for the Requestrequest - The Api Request ObjectdruidQuery - The druid queryresponse - The Async responseprotected String getKey(DruidAggregationQuery<?> druidQuery) throws com.fasterxml.jackson.core.JsonProcessingException
druidQuery - The druid query.com.fasterxml.jackson.core.JsonProcessingException - if the druid query cannot be mapped to JsonCopyright © 2016–2018 Yahoo! Inc.. All rights reserved.