mcardle     2005/11/08 11:53:25 CET

  Modified files:
    src/org/jahia/esi/cache FragmentCache.java 
  Log:
  * supports dummy cache entries which contain the appropriate error message 
why a given object/fragment wasn't retrieved correctly.
  
  Revision  Changes    Path
  1.5       +37 -0     esi_server/src/org/jahia/esi/cache/FragmentCache.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/esi_server/src/org/jahia/esi/cache/FragmentCache.java.diff?r1=1.4&r2=1.5&f=h
  
  
  
  Index: FragmentCache.java
  ===================================================================
  RCS file: 
/home/cvs/repository/esi_server/src/org/jahia/esi/cache/FragmentCache.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FragmentCache.java        4 Nov 2005 16:51:02 -0000       1.4
  +++ FragmentCache.java        8 Nov 2005 10:53:25 -0000       1.5
  @@ -101,6 +101,43 @@
                   EsiConst.DEFAULT_DELAY );
       }
   
  +    public synchronized void addUnfectched(String urlKey, HttpMethod method, 
String errorMsg,
  +                                           String Url    ) {
  +        String byteContentHash = getMD5Hash(errorMsg.getBytes());
  +        UrlCacheObject newUrlObj = null;
  +        //otherwise create a new one
  +
  +        //adds a dummy entry that contains the error message and
  +        //that will expire instantly so that we don't keep serving
  +        // the erroneous entry but try to fetch it each time
  +        newUrlObj = new UrlCacheObject(byteContentHash, method,
  +                Url,
  +                null,
  +                null,
  +                null,
  +                null,
  +                0,
  +                (new Date()).getTime(),
  +                0);
  +        hashCache.put(urlKey,newUrlObj);
  +        log.info("Added Unfectched Error Fragment in cache UrlCacheObject : 
" + newUrlObj);
  +
  +        //add associated it to a contentCache entry
  +        if (!contentCache.containsKey(byteContentHash)) {
  +            ContentCacheObject newContentObj = new 
ContentCacheObject(errorMsg.getBytes());
  +            contentCache.put(byteContentHash, newContentObj);
  +            EsiStats.getInstance().contentCacheMiss();
  +            log.debug("Content Cache Miss: recieved content 
["+byteContentHash +"] was not in cache (for request urlKey ["+urlKey +"])");
  +        }
  +        //might already be stored in contentCache, if so, don't add it again
  +        else {
  +            ContentCacheObject contentObj = (ContentCacheObject) 
contentCache.get(byteContentHash);
  +            contentObj.incReferenceCount();
  +            EsiStats.getInstance().contentCacheHit();
  +            log.debug("Content Cache Hit: recieved content 
["+byteContentHash +"] already in cache (for request urlKey ["+urlKey +"])");
  +        }
  +    }
  +
       public synchronized void add(String urlKey, HttpMethod method, byte[] 
byteContent,
                                    String Url,
                                    String[] refObjs,
  

Reply via email to