/** * Getter to the cache entry to be removed * * @return the cache entry */ public CacheEntry getEntry() { return new CacheEntry(key, getOldElement()); } }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
/** * {@inheritDoc} */ public void throwAway(final CacheWriter cacheWriter, final RuntimeException e) { Element element = entry.getElement(); if (element == null) { element = new Element(entry.getKey(), null); } cacheWriter.throwAway(element, SingleOperationType.DELETE, e); }
/** * {@inheritDoc} */ public Object getKey() { return entry.getKey(); }
private Element removeInternal(final StoreRemoveCommand command) { Element element = command.getEntry().getElement(); getOrCreateTransactionContext().addCommand(command, element); return element; }
@Override public void delete(CacheEntry entry) { async.add(new DeleteAsyncOperation(entry.getKey(), entry.getElement())); }
/** * {@inheritDoc} */ public void delete(final CacheEntry entry) { readLock.lock(); try { getQueue(entry.getKey()).delete(entry); } finally { readLock.unlock(); } }
/** * {@inheritDoc} * * Remove data and keys from the underlying store for the given collection of keys, if present. If this operation fails * (by throwing an exception) after a partial success, the convention is that keys which have been erased successfully * are to be removed from the specified keys, indicating that the erase operation for the keys left in the collection * has failed or has not been attempted. */ public void deleteAll(Collection<CacheEntry> entries) throws CacheException { Set<javax.cache.Cache.Entry<K, V>> javaxCacheEntries = new HashSet<javax.cache.Cache.Entry<K, V>>(); for (CacheEntry e : entries) { javaxCacheEntries.add(new JCacheEntry<K, V>(e.getElement(), keyType, valueType)); } jsr107CacheWriter.deleteAll(javaxCacheEntries); }
private BatchAsyncOperation createBatchOprForType(Class operationClass, Collection<SingleAsyncOperation> operations) { if (operationClass == WriteAsyncOperation.class) { final List<Element> elements = new ArrayList<Element>(); for (SingleAsyncOperation operation : operations) { elements.add(operation.getElement()); } return new WriteAllAsyncOperation(elements); } if (operationClass == DeleteAsyncOperation.class) { List<CacheEntry> entries = new ArrayList<CacheEntry>(); for (SingleAsyncOperation operation : operations) { entries.add(new CacheEntry(operation.getKey(), operation.getElement())); } return new DeleteAllAsyncOperation(entries); } throw new RuntimeException("no batch operation created for " + operationClass.getName()); }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
/** * {@inheritDoc} */ public void throwAway(final CacheWriter cacheWriter, final RuntimeException e) { Element element = entry.getElement(); if (element == null) { element = new Element(entry.getKey(), null); } cacheWriter.throwAway(element, SingleOperationType.DELETE, e); }
/** * {@inheritDoc} */ public void delete(CacheEntry entry) { queueWriteLock.lock(); try { waitForQueueSizeToDrop(); if (stopping || stopped) { throw new CacheException("The entry for key '" + entry.getKey() + "' couldn't be deleted through the write-behind " + "queue for cache '" + cacheName + "' since it's not started."); } addItem(new DeleteOperation(entry)); if (getQueueSize() + 1 < maxQueueSize) { queueIsFull.signal(); } queueIsEmpty.signal(); } finally { queueWriteLock.unlock(); } }
/** * {@inheritDoc} * * Remove data and keys from the underlying store for the given collection of keys, if present. If this operation fails * (by throwing an exception) after a partial success, the convention is that keys which have been erased successfully * are to be removed from the specified keys, indicating that the erase operation for the keys left in the collection * has failed or has not been attempted. */ public void deleteAll(Collection<CacheEntry> entries) throws CacheException { Set<javax.cache.Cache.Entry<K, V>> javaxCacheEntries = new HashSet<javax.cache.Cache.Entry<K, V>>(); for (CacheEntry e : entries) { javaxCacheEntries.add(new JCacheEntry<K, V>(e.getElement(), keyType, valueType)); } jsr107CacheWriter.deleteAll(javaxCacheEntries); }
private synchronized Element removeInternal(Object key, CacheWriterManager writerManager) throws CacheException { // remove single item. removeObserver.begin(); Element element = (Element) map.remove(key); if (writerManager != null) { writerManager.remove(new CacheEntry(key, element)); } removeObserver.end(RemoveOutcome.SUCCESS); if (element != null) { return element; } else { return null; } }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }
/** * {@inheritDoc} */ public void throwAway(final CacheWriter cacheWriter, final RuntimeException e) { Element element = entry.getElement(); if (element == null) { element = new Element(entry.getKey(), null); } cacheWriter.throwAway(element, SingleOperationType.DELETE, e); }
/** * {@inheritDoc} */ public Object getKey() { return entry.getKey(); }
private Element removeInternal(final StoreRemoveCommand command) { Element element = command.getEntry().getElement(); getOrCreateTransactionContext().addCommand(command, element); return element; }
/** * {@inheritDoc} */ public final Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException { if (key == null) { return null; } // remove single item. Element element; final ReentrantReadWriteLock.WriteLock writeLock = map.lockFor(key).writeLock(); writeLock.lock(); try { element = map.remove(key); if (writerManager != null) { writerManager.remove(new CacheEntry(key, element)); } } finally { writeLock.unlock(); } if (element == null && LOG.isDebugEnabled()) { LOG.debug(cache.getName() + "Cache: Cannot remove entry as key " + key + " was not found"); } return element; }
private CacheEntry duplicateCacheEntryElement(CacheEntry entry) { if (null == entry.getElement()) { return entry; } else { Element element = entry.getElement(); return new CacheEntry(entry.getKey(), new Element(element.getObjectKey(), element.getObjectValue(), element.getVersion(), element.getCreationTime(), element.getLastAccessTime(), element.getHitCount(), false, element.getTimeToLive(), element.getTimeToIdle(), element.getLastUpdateTime())); } }