Package grails.plugin.cache.web

Examples of grails.plugin.cache.web.PageInfo


          updates.putAll(status.updates);
        }
        // render cached response
        else {
          logRequestDetails(request, getContext(), "Caching enabled for request");
          PageInfo pageInfo = buildCachedPageInfo(request, response, status);
          writeResponse(request, response, pageInfo);
          return;
        }
      }

      logRequestDetails(request, getContext(), "Caching enabled for request");
      PageInfo pageInfo = buildNewPageInfo(request, response, chain, status, operationsByType);
      writeResponse(request, response, pageInfo);

      inspectAfterCacheEvicts(operationsByType.get(EVICT));

      if (!updates.isEmpty()) {
View Full Code Here


    Timer timer = new Timer(getCachedUri(request));
    timer.start();

    String key = calculateKey(request);
    PageInfo pageInfo;
    try {
      // Page is not cached - build the response, cache it, and send to client
      pageInfo = buildPage(request, response, chain);
      if (pageInfo.isOk()) {
        Object noCache = pageInfo.getCacheDirectives().get("no-cache");
        if (noCache instanceof Boolean && ((Boolean)noCache)) {
          log.debug("Response ok but Cache-Control: no-cache is present, not caching");
          releaseCacheLocks(operationsByType, key);
        }
        else {
          Collection<Cache> caches = new ArrayList<Cache>();
          for (CacheOperationContext operationContext : operationsByType.get(UPDATE)) {
            for (Cache cache : operationContext.getCaches()) {
              caches.add(cache);
            }
          }
          update(caches, pageInfo, cacheStatus, key);
        }
      }
      else {
        for (CacheOperationContext operationContext : operationsByType.get(UPDATE)) {
          for (Cache cache : operationContext.getCaches()) {
            log.debug("Response not ok ({}). Putting null into cache {} with key {}",
                new Object[] { pageInfo.getStatusCode(), cache.getName(), key } );
          }
        }
        releaseCacheLocks(operationsByType, key);
      }
    }
View Full Code Here

    Timer timer = new Timer(getCachedUri(request));
    timer.start();

    String key = calculateKey(request);
    PageInfo pageInfo;
    ValueWrapper element = cacheStatus.valueWrapper;
    log.debug("Serving cached content for {}", key);
    pageInfo = (PageInfo) element.get();

    for (Map.Entry<String, ? extends Serializable> entry : pageInfo.getRequestAttributes().entrySet()) {
      request.setAttribute(entry.getKey(), entry.getValue());
    }

    // As the page is cached, we need to add an instance of the associated
    // controller to the request. This is required by GrailsLayoutDecoratorMapper
View Full Code Here

    String contentType = wrapper.getContentType();
    if (!StringUtils.hasLength(contentType)) {
      contentType = response.getContentType();
    }

    return new PageInfo(wrapper.getStatus(), contentType, out.toByteArray(),
      false, timeToLiveSeconds, wrapper.getAllHeaders(), wrapper.getCookies(), cacheableRequestAttributes);
  }
View Full Code Here

          updates.putAll(status.updates);
        }
        // render cached response
        else {
          logRequestDetails(request, getContext(), "Caching enabled for request");
          PageInfo pageInfo = buildCachedPageInfo(request, response, status);
          writeResponse(request, response, pageInfo);
          return;
        }
      }

      logRequestDetails(request, getContext(), "Caching enabled for request");
      PageInfo pageInfo = buildNewPageInfo(request, response, chain, status, operationsByType);
      writeResponse(request, response, pageInfo);

      inspectAfterCacheEvicts(operationsByType.get(EVICT));

      if (!updates.isEmpty()) {
View Full Code Here

    Timer timer = new Timer(getCachedUri(request));
    timer.start();

    String key = calculateKey(request);
    PageInfo pageInfo;
    try {
      // Page is not cached - build the response, cache it, and send to client
      pageInfo = buildPage(request, response, chain);
      if (pageInfo.isOk()) {
        Object noCache = pageInfo.getCacheDirectives().get("no-cache");
        if (noCache instanceof Boolean && ((Boolean)noCache)) {
          log.debug("Response ok but Cache-Control: no-cache is present, not caching");
          releaseCacheLocks(operationsByType, key);
        }
        else {
          Collection<Cache> caches = new ArrayList<Cache>();
          for (CacheOperationContext operationContext : operationsByType.get(UPDATE)) {
            for (Cache cache : operationContext.getCaches()) {
              caches.add(cache);
            }
          }
          update(caches, pageInfo, cacheStatus, key);
        }
      }
      else {
        for (CacheOperationContext operationContext : operationsByType.get(UPDATE)) {
          for (Cache cache : operationContext.getCaches()) {
            log.debug("Response not ok ({}). Putting null into cache {} with key {}",
                new Object[] { pageInfo.getStatusCode(), cache.getName(), key } );
          }
        }
        releaseCacheLocks(operationsByType, key);
      }
    }
View Full Code Here

    Timer timer = new Timer(getCachedUri(request));
    timer.start();

    String key = calculateKey(request);
    PageInfo pageInfo;
    ValueWrapper element = cacheStatus.valueWrapper;
    try {
      log.debug("Serving cached content for {}", key);
      pageInfo = (PageInfo) element.get();

      for (Map.Entry<String, ? extends Serializable> entry : pageInfo.getRequestAttributes().entrySet()) {
        request.setAttribute(entry.getKey(), entry.getValue());
      }

      // As the page is cached, we need to add an instance of the associated
      // controller to the request. This is required by GrailsLayoutDecoratorMapper
View Full Code Here

    String contentType = wrapper.getContentType();
    if (!StringUtils.hasLength(contentType)) {
      contentType = response.getContentType();
    }

    return new PageInfo(wrapper.getStatus(), contentType, out.toByteArray(),
      false, timeToLiveSeconds, wrapper.getAllHeaders(), wrapper.getCookies(), cacheableRequestAttributes);
  }
View Full Code Here

TOP

Related Classes of grails.plugin.cache.web.PageInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.