Examples of ICacheEntry


Examples of org.directmemory.ICacheEntry

  @Test
    @PerfTest(duration = 10000, threads = 5)
    @Required(max = 1500, average = 1)
  public void onlyWrites() throws IOException {
      DummyObject object2add = nextObject();
      ICacheEntry entry = cache.put(object2add.getName(), object2add);
      assertNotNull(entry);
  }
View Full Code Here

Examples of org.directmemory.ICacheEntry

   
    long mySize = 0;
   
      Iterator<ICacheEntry> iter = entries.values().iterator();
    while (iter.hasNext()) {
      ICacheEntry entry = iter.next();
      if (!entry.expired()) {
        DummyObject dummy = (DummyObject) cache.get(entry.getKey());
        assertNotNull(dummy);
        assertEquals(entry.getKey(), dummy.getName());
      }
      mySize+=entry.size();
    }

    logger.debug("**** computed size is: " + mySize)
    logger.debug(cache.toString())
    }
View Full Code Here

Examples of org.directmemory.ICacheEntry

 
  public ICacheEntry delete(String key) {

    logger.info("trying to remove entry with key '" + key + "'")

    ICacheEntry entry = null;
   
    entry = entries.remove(key);
    signalWeDeleted(key);
   
    if (entry != null) {
      usedMemory.addAndGet(-entry.size());
      entry.dispose();
      logger.info("object with key '" + key + "' disposed");
    }

    return entry;
  }
View Full Code Here

Examples of org.xlightweb.IHttpCache.ICacheEntry

      }
     
        
      // handle caching
      try {
            ICacheEntry ce = cache.get(request, minFresh);
            if ((ce != null) && !(ce.isAfter(maxOld))) {
               
                // must revalidate?
                if (ce.mustRevalidate(minFresh)) {
                   
                    if (isOnlyIfCached) {
                        countCacheMiss++;
                        statistics.addMiss();
                       
                        exchange.sendError(504);
                       
                    } else {
                        IValidationHandler validationHdl = new IValidationHandler() {
                           
                            public void onRevalidated(boolean isNotModified, HttpCache.AbstractCacheEntry ce) {
                               
                                if (isNotModified) {
                                    try {
                                        countCacheHit++;
                                        statistics.addHit();
                                       
                                        IHttpResponse resp = ce.newResponse();
                                        resp.setHeader(XHEADER_NAME, "HIT - revalidated (xLightweb)");
                                        resp.setAttribute(CACHE_HIT, "HIT (revalidated)");
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                } else  {
                                    try {
                                        countCacheMiss++;
                                        statistics.addMiss();
                                       
                                        IHttpResponse resp = ce.newResponse();
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                }
                            }
                           
                            public void onException(IOException ioe) {
                                exchange.sendError(ioe);
                            }
                           
                        };

                        ce.revalidate(exchange, validationHdl);
                    }
                 
                // .. revalidation is not required
                } else {
                    countCacheHit++;
                    statistics.addHit();
                    IHttpResponse resp = ce.newResponse();
                    resp.setHeader(XHEADER_NAME, "HIT  (xLightweb)");
                    resp.setAttribute(CACHE_HIT, "HIT");

                    exchange.send(resp);
                }
View Full Code Here

Examples of org.xlightweb.IHttpCache.ICacheEntry

      }
     
        
      // handle caching
      try {
            ICacheEntry ce = cache.get(request, minFresh);
            if ((ce != null) && !(ce.isAfter(maxOld))) {
               
                // must revalidate?
                if (ce.mustRevalidate(minFresh)) {
                   
                    if (isOnlyIfCached) {
                        countCacheMiss++;
                        statistics.addMiss();
                       
                        exchange.sendError(504);
                       
                    } else {
                        IValidationHandler validationHdl = new IValidationHandler() {
                           
                            public void onRevalidated(boolean isNotModified, HttpCache.AbstractCacheEntry ce) {
                               
                                if (isNotModified) {
                                    try {
                                        countCacheHit++;
                                        statistics.addHit();
                                       
                                        IHttpResponse resp = ce.newResponse();
                                        resp.setHeader(XHEADER_NAME, "HIT - revalidated (xLightweb)");
                                        resp.setAttribute(CACHE_HIT, "HIT (revalidated)");
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                } else  {
                                    try {
                                        countCacheMiss++;
                                        statistics.addMiss();
                                       
                                        IHttpResponse resp = ce.newResponse();
                                        exchange.send(resp);
                                    } catch (IOException ioe) {
                                        exchange.sendError(ioe);
                                    }
                                }
                            }
                           
                            public void onException(IOException ioe) {
                                exchange.sendError(ioe);
                            }
                           
                        };

                        ce.revalidate(exchange, validationHdl);
                    }
                 
                // .. revalidation is not required
                } else {
                    countCacheHit++;
                    statistics.addHit();
                    IHttpResponse resp = ce.newResponse();
                    resp.setHeader(XHEADER_NAME, "HIT  (xLightweb)");
                    resp.setAttribute(CACHE_HIT, "HIT");

                    exchange.send(resp);
                }
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.