Examples of CachedResponse


Examples of com.anthavio.httl.cache.CachedResponse

    if (softTtl <= 0 && Cutils.isEmpty(etag) && lastModified <= 0) {
      return null;
    }
    long hardTtl = softTtl > 0 ? softTtl : 10; //XXX default hardTtl is 10 seconds - should be parametrized

    CachedResponse cachedResponse = new CachedResponse(request, response);
    return new CacheEntry<CachedResponse>(cachedResponse, hardTtl, softTtl);

  }
View Full Code Here

Examples of com.bazaarvoice.dropwizard.caching.CachedResponse

            int statusCode = readStatusCode(headerReader);
            MultivaluedMap<String, String> headers = readHeaders(headerReader);
            byte[] responseContent = Arrays.copyOfRange(cachedData, headerSeparatorIndex + HEADER_SEPARATOR.length, cachedData.length);

            return new CachedResponse(statusCode, headers, responseContent);
        } catch (IOException ex) {
            throw new RuntimeException("Corrupted cache entry", ex);
        }
    }
View Full Code Here

Examples of org.apache.abdera.protocol.client.cache.CachedResponse

        Cache cache = getCache();
        CacheDisposition disp =
          (useCache(method,options)) ?
            cache.getDisposition(uri, options) :
            CacheDisposition.TRANSPARENT;
        CachedResponse cached_response = cache.get(uri, options);
        disp = (!disp.equals(CacheDisposition.TRANSPARENT) &&
                mustRevalidate(options, cached_response)) ?
                  CacheDisposition.STALE :
                  disp;
        switch(disp) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return cached_response;
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null && cached_response.getEntityTag() != null) {
              options.setIfModifiedSince(cached_response.getLastModified());
              options.setIfNoneMatch(cached_response.getEntityTag().toString());
            } else {
              disp = CacheDisposition.TRANSPARENT;
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
View Full Code Here

Examples of org.apache.abdera.protocol.client.cache.CachedResponse

      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      HttpMethod httpMethod = null;
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            httpMethod =
              MethodHelper.createMethod(
View Full Code Here

Examples of org.apache.abdera.protocol.client.cache.CachedResponse

    RequestOptions options) {
      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
              MethodHelper.createMethod(
View Full Code Here

Examples of org.apache.abdera.protocol.client.cache.CachedResponse

    public ClientResponse execute(String method, String uri, RequestEntity entity, RequestOptions options) {
        boolean usecache = useCache(method, options);
        options = options != null ? options : getDefaultRequestOptions();
        try {
            Cache cache = getCache();
            CachedResponse cached_response = cache.get(uri);
            switch (getCacheDisposition(usecache, uri, options, cached_response)) {
                case FRESH: // CACHE HIT: FRESH
                    if (cached_response != null)
                        return checkRequestException(cached_response, options);
                case STALE: // CACHE HIT: STALE
                    // revalidate the cached entry
                    if (cached_response != null) {
                        if (cached_response.getEntityTag() != null)
                            options.setIfNoneMatch(cached_response.getEntityTag().toString());
                        else if (cached_response.getLastModified() != null)
                            options.setIfModifiedSince(cached_response.getLastModified());
                        else
                            options.setNoCache(true);
                    }
                default: // CACHE MISS
                    HttpMethod httpMethod = MethodHelper.createMethod(method, uri, entity, options);
View Full Code Here

Examples of org.apache.abdera.protocol.client.cache.CachedResponse

    RequestOptions options) {
      boolean usecache = useCache(method,options);
      options = options != null ? options : getDefaultRequestOptions();
      try {
        Cache cache = getCache();
        CachedResponse cached_response = cache.get(uri);
        switch(
          getCacheDisposition(
            usecache,
            uri,
            options,
            cached_response)) {
          case FRESH:                                                            // CACHE HIT: FRESH
            if (cached_response != null)
              return checkRequestException(
                cached_response,options);
          case STALE:                                                            // CACHE HIT: STALE
            // revalidate the cached entry
            if (cached_response != null) {
              if (cached_response.getEntityTag() != null)
                options.setIfNoneMatch(cached_response.getEntityTag().toString());
              else if (cached_response.getLastModified() != null)
                options.setIfModifiedSince(cached_response.getLastModified());
              else options.setNoCache(true);
            }
          default:                                                               // CACHE MISS
            HttpMethod httpMethod =
              MethodHelper.createMethod(
View Full Code Here

Examples of org.apache.cocoon.caching.CachedResponse

    protected void cacheResults(Environment environment, OutputStream osthrows Exception {
        if (this.toCacheKey != null) {
            // See if there is an expires object for this resource.               
            Long expiresObj = (Long) environment.getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT);
            if ( this.cacheCompleteResponse ) {
                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                          ((CachingOutputStream)os).getContent(),
                                          expiresObj);
                this.cache.store(environment.getObjectModel(),
                                 this.toCacheKey,
                                 response);
            } else {
                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                          (byte[])this.xmlSerializer.getSAXFragment(),
                                          expiresObj);
                this.cache.store(environment.getObjectModel(),
                                 this.toCacheKey,
                                 response);
View Full Code Here

Examples of org.apache.cocoon.caching.CachedResponse

               
                    SourceUtil.toSAX(source, serializer);
               
                    SourceValidity[] validities = new SourceValidity[1];
                    validities[0] = new ExpiresValidity(((Long)object[2]).longValue() * 1000); // milliseconds!
                    CachedResponse response = new CachedResponse(validities,
                                                                 (byte[])serializer.getSAXFragment());
                    ((IncludeCacheStorageProxy)object[0]).put(uri, response);
                    
                } catch (Exception ignore) {
                    // all exceptions are ignored!
View Full Code Here

Examples of org.apache.cocoon.caching.CachedResponse

            if ( this.cacheCompleteResponse ) {
                if (this.getLogger().isDebugEnabled()) {
                    this.getLogger().debug("Cached: caching complete response; pSisze"
                                           + this.toCacheKey.size() + " Key " + this.toCacheKey);
                }
                CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                          ((CachingOutputStream)os).getContent());
                this.cache.store(environment.getObjectModel(),
                                 this.toCacheKey.copy(),
                                 response);
        //
        // Scan back along the pipelineCacheKey for
        // for any cachepoint(s)
        //
            this.toCacheKey.removeUntilCachePoint();

        //
        // adjust the validities object
        // to reflect the new length of the pipeline cache key.
        //
        // REVISIT: Is it enough to simply reduce the length of the validities array?
        //
                if (this.toCacheKey.size()>0) {
                    SourceValidity[] copy = new SourceValidity[this.toCacheKey.size()];
                    System.arraycopy(this.toCacheSourceValidities, 0,
                                     copy, 0, copy.length);
                    this.toCacheSourceValidities = copy;
                }
            }

            if (this.toCacheKey.size()>0) {
                ListIterator itt = this.xmlSerializerArray.listIterator(this.xmlSerializerArray.size());
                while (itt.hasPrevious()) {
                    XMLSerializer serializer = (XMLSerializer) itt.previous();
                    CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
                                              (byte[])serializer.getSAXFragment());
                    this.cache.store(environment.getObjectModel(),
                                     this.toCacheKey.copy(),
                                     response);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.