public Entry put(String key, MediaType mediaType, MultivaluedMap<String, String> headers, byte[] cached, int expires, String etag, String lastModified) { return put(new CacheEntry(key, headers, cached, expires, etag, lastModified, mediaType)); } }
/** * Makes the client proxy cacheable. Returns the cache that will hold * returned values from the server. * * @param clientProxy * @return */ public static LightweightBrowserCache makeCacheable(Object clientProxy) { LightweightBrowserCache cache = new LightweightBrowserCache(); makeCacheable(clientProxy, cache); return cache; }
public LightweightBrowserCache() { this(new MapCache()); }
public Entry put(String key, MediaType mediaType, MultivaluedMap<String, String> headers, byte[] cached, int expires, String etag, String lastModified) { Entry previousValue = internalCache.get(key, mediaType); int sizeDiff = -1; if (previousValue == null) sizeDiff = cached.length; else sizeDiff = cached.length - previousValue.getCached().length; if (bytes.addAndGet(sizeDiff) > maxBytes) { clear(); bytes.addAndGet(sizeDiff); } return internalCache.put(key, mediaType, headers, cached, expires, etag, lastModified); }
private BaseClientResponse createClientResponse(ClientRequest request, BrowserCache.Entry entry) { BaseClientResponse response = new BaseClientResponse(new CachedStreamFactory(entry)); response.setStatus(200); response.setHeaders(entry.getHeaders()); response.setProviderFactory(request.getProviderFactory()); return response; }
public Entry get(String key, MediaType accept) { return internalCache.get(key, accept); }
public Entry getAny(String key) { return internalCache.getAny(key); }
public void clear() { internalCache.clear(); bytes.set(0); } }
private ClientResponse cache(ClientRequest request, ClientResponse response) throws Exception { if (response.getStatus() != 200) return response; return cacheIfPossible(request, (BaseClientResponse) response); }
public Entry put(String key, MediaType mediaType, MultivaluedMap<String, String> headers, byte[] cached, int expires, String etag, String lastModified) { Entry previousValue = internalCache.get(key, mediaType); int sizeDiff = -1; if (previousValue == null) sizeDiff = cached.length; else sizeDiff = cached.length - previousValue.getCached().length; if (bytes.addAndGet(sizeDiff) > maxBytes) { clear(); bytes.addAndGet(sizeDiff); } return internalCache.put(key, mediaType, headers, cached, expires, etag, lastModified); }
public Entry put(String key, MediaType mediaType, MultivaluedMap<String, String> headers, byte[] cached, int expires, String etag, String lastModified) { return put(new CacheEntry(key, headers, cached, expires, etag, lastModified, mediaType)); } }
/** * Makes the client proxy cacheable. Returns the cache that will hold * returned values from the server. * * @param clientProxy * @return */ public static LightweightBrowserCache makeCacheable(Object clientProxy) { LightweightBrowserCache cache = new LightweightBrowserCache(); makeCacheable(clientProxy, cache); return cache; }
private BaseClientResponse createClientResponse(ClientRequest request, BrowserCache.Entry entry) { BaseClientResponse response = new BaseClientResponse(new CachedStreamFactory(entry)); response.setStatus(200); response.setHeaders(entry.getHeaders()); response.setProviderFactory(request.getProviderFactory()); return response; }
public LightweightBrowserCache() { this(new MapCache()); }
public Entry get(String key, MediaType accept) { return internalCache.get(key, accept); }
public Entry getAny(String key) { return internalCache.getAny(key); }
public void clear() { internalCache.clear(); bytes.set(0); } }
private ClientResponse cache(ClientRequest request, ClientResponse response) throws Exception { if (response.getStatus() != 200) return response; return cacheIfPossible(request, (BaseClientResponse) response); }