List of usage examples for org.apache.http.client.cache HttpCacheUpdateCallback update
HttpCacheEntry update(HttpCacheEntry existing) throws IOException;
From source file:org.eclipse.thym.core.internal.util.BundleHttpCacheStorage.java
@Override public void updateEntry(String key, HttpCacheUpdateCallback callback) throws IOException, HttpCacheUpdateException { HttpCacheEntry existing = getEntry(key); HttpCacheEntry updated = callback.update(existing); if (updated == null) { removeEntry(key);/* www . j a v a 2 s .com*/ } else { putEntry(key, updated); } }
From source file:com.machinepublishers.jbrowserdriver.HttpCache.java
/** * {@inheritDoc}/* w ww .j a v a2 s . c o m*/ */ @Override public void updateEntry(String key, HttpCacheUpdateCallback callback) throws IOException, HttpCacheUpdateException { HttpCacheEntry entry = callback.update(getEntry(key)); putEntry(key, entry); }
From source file:gr.wavesoft.webng.io.cache.DiskCacheStorage.java
public void updateEntry(String string, HttpCacheUpdateCallback hcuc) throws IOException, HttpCacheUpdateException { String key = WebNGSystem.SHA1Sum(string); HttpCacheEntry hce = hcuc.update(getEntry(key)); Database.assignArgStatements(stmUpdate, new Object[] { serialize(hce) }); }
From source file:org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage.java
public void updateEntry(final String url, final HttpCacheUpdateCallback callback) throws HttpCacheUpdateException, IOException { int numRetries = 0; final String key = getCacheKey(url); if (key == null) { throw new HttpCacheUpdateException("couldn't generate cache key"); }//from w ww .j a v a 2 s . co m do { try { final CASValue<Object> v = client.gets(key); MemcachedCacheEntry mce = (v == null) ? null : reconstituteEntry(v.getValue()); if (mce != null && (!url.equals(mce.getStorageKey()))) { mce = null; } final HttpCacheEntry existingEntry = (mce == null) ? null : mce.getHttpCacheEntry(); final HttpCacheEntry updatedEntry = callback.update(existingEntry); if (existingEntry == null) { putEntry(url, updatedEntry); return; } else { final byte[] updatedBytes = serializeEntry(url, updatedEntry); final CASResponse casResult = client.cas(key, v.getCas(), updatedBytes); if (casResult != CASResponse.OK) { numRetries++; } else { return; } } } catch (final OperationTimeoutException ex) { throw new MemcachedOperationTimeoutException(ex); } } while (numRetries <= maxUpdateRetries); throw new HttpCacheUpdateException("Failed to update"); }