use of com.adobe.acs.commons.httpcache.engine.CacheContent in project acs-aem-commons by Adobe-Consulting-Services.
the class HttpCacheEngineImpl method deliverCacheContent.
@Override
public boolean deliverCacheContent(SlingHttpServletRequest request, SlingHttpServletResponse response, HttpCacheConfig cacheConfig) throws HttpCacheKeyCreationException, HttpCacheDataStreamException, HttpCachePersistenceException {
// Get the cached content from cache
CacheContent cacheContent = getCacheStore(cacheConfig).getIfPresent(cacheConfig.buildCacheKey(request));
if (!isRequestDeliverableFromCacheAccordingToHandlingRules(request, response, cacheConfig, cacheContent)) {
return false;
}
prepareCachedResponse(response, cacheContent);
return executeCacheContentDeliver(request, response, cacheContent);
}
use of com.adobe.acs.commons.httpcache.engine.CacheContent in project acs-aem-commons by Adobe-Consulting-Services.
the class EntryNodeMapVisitorTest method testNoEntries.
@Test
public void testNoEntries() throws Exception {
final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
settings.setEntryNodeCount(0);
final Node rootNode = new RootNodeMockFactory(settings).build();
final EntryNodeMapVisitor visitor = getMockedNodeMapVisitor();
visitor.visit(rootNode);
final Map<CacheKey, CacheContent> cache = visitor.getCache();
assertTrue(cache.isEmpty());
}
use of com.adobe.acs.commons.httpcache.engine.CacheContent in project acs-aem-commons by Adobe-Consulting-Services.
the class EntryNodeMapVisitorTest method test5BucketDepth.
@Test
public void test5BucketDepth() throws Exception {
final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
settings.setEntryNodeCount(10);
settings.setBucketDepth(5);
final Node rootNode = new RootNodeMockFactory(settings).build();
final EntryNodeMapVisitor visitor = getMockedNodeMapVisitor();
visitor.visit(rootNode);
final Map<CacheKey, CacheContent> cache = visitor.getCache();
assertEquals(10, cache.size());
}
use of com.adobe.acs.commons.httpcache.engine.CacheContent in project acs-aem-commons by Adobe-Consulting-Services.
the class MemHttpCacheStoreImpl method getIfPresent.
@Override
public CacheContent getIfPresent(CacheKey key) {
MemCachePersistenceObject value = cache.getIfPresent(key);
if (null == value) {
return null;
}
// Increment hit count
value.incrementHitCount();
return new CacheContent(value.getStatus(), value.getCharEncoding(), value.getContentType(), value.getHeaders(), new ByteArrayInputStream(value.getBytes()));
}
use of com.adobe.acs.commons.httpcache.engine.CacheContent in project acs-aem-commons by Adobe-Consulting-Services.
the class EntryNodeWriterMocks method mockCacheContent.
private void mockCacheContent() {
cacheContent = mock(CacheContent.class);
when(cacheContent.getCharEncoding()).thenReturn(arguments.cacheContentCharEncoding);
when(cacheContent.getContentType()).thenReturn(arguments.cacheContentType);
when(cacheContent.getInputDataStream()).thenReturn(arguments.cacheContent);
when(cacheContent.getStatus()).thenReturn(arguments.status);
when(cacheContent.getHeaders()).thenReturn(arguments.cacheContentHeaders);
when(cacheContent.getTempSink()).thenReturn(new MemTempSinkImpl());
}
Aggregations