Repository: incubator-ignite Updated Branches: refs/heads/ignite-gg-9858 c8488548e -> cb3169791
#ignite-333: Add clearLocally method to IgniteCache. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/def04679 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/def04679 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/def04679 Branch: refs/heads/ignite-gg-9858 Commit: def0467972450d800756177773ae76488a4d19ac Parents: 4a072f4 Author: ivasilinets <ivasilin...@gridgain.com> Authored: Tue Mar 10 12:55:03 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Tue Mar 10 12:55:03 2015 +0300 ---------------------------------------------------------------------- .../java/org/apache/ignite/IgniteCache.java | 20 +++++++++++++++++++- .../processors/cache/IgniteCacheProxy.java | 14 +++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/def04679/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index 21bf907..a378101 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -398,7 +398,25 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS * if entry was in use at the time of this method invocation and could not be * cleared. */ - public boolean clear(K key); + public boolean clearLocally(K key); + + /** + * Clears all entry from this cache and swap storage only if the entry + * is not currently locked, and is not participating in a transaction. + * <p/> + * If {@link CacheConfiguration#isSwapEnabled()} is set to {@code true} and + * {@link CacheFlag#SKIP_SWAP} is not enabled, the evicted entries will + * also be cleared from swap. + * <p/> + * Note that this operation is local as it merely clears + * an entry from local cache. It does not remove entries from + * remote caches or from underlying persistent storage. + * This method is not transactionally consistent. + * Transactional semantics must be guaranteed outside of Ignite. + * <h2 class="header">Cache Flags</h2> + * This method is not available if flag {@link CacheFlag#READ} are set on projection. + */ + public void clearLocally(); /** {@inheritDoc} */ @IgniteAsyncSupported http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/def04679/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java index 8470a8c..e179e3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java @@ -1061,7 +1061,7 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V } /** {@inheritDoc} */ - @Override public boolean clear(K key) { + @Override public boolean clearLocally(K key) { GridCacheProjectionImpl<K, V> prev = gate.enter(prj); try { @@ -1075,6 +1075,18 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K, V } /** {@inheritDoc} */ + @Override public void clearLocally() { + GridCacheProjectionImpl<K, V> prev = gate.enter(prj); + + try { + delegate.clearLocally(); + } + finally { + gate.leave(prev); + } + } + + /** {@inheritDoc} */ @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor, Object... args) throws EntryProcessorException { try {