FileDocCategorySizeDatePackage
MemoryCache.javaAPI DocExample1297Sun Dec 12 10:55:18 GMT 2004None

MemoryCache

public class MemoryCache extends ResponseCache

Fields Summary
private Map
responses
private int
maxEntries
Constructors Summary
public MemoryCache()

  
  
    
    this(100);
  
public MemoryCache(int maxEntries)

    this.maxEntries = maxEntries;
  
Methods Summary
public java.net.CacheResponseget(java.net.URI uri, java.lang.String requestMethod, java.util.Map requestHeaders)

     
     SimpleCacheResponse response = responses.get(uri);
     if (response != null && response.isExpired()) { // check expiration date
       responses.remove(response);
       response = null;
     }
     return response;
     
  
public java.net.CacheRequestput(java.net.URI uri, java.net.URLConnection uc)

     
     if (responses.size() >= maxEntries) return null;
     
     String cacheControl = uc.getHeaderField("Cache-Control");
     if (cacheControl != null && cacheControl.indexOf("no-cache") >= 0) {
       return null;
     }
   
     SimpleCacheRequest request = new SimpleCacheRequest();
     SimpleCacheResponse response = new SimpleCacheResponse(request, uc);
   
     responses.put(uri, response);
     return request;