ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [1/2] incubator-ignite git commit: #ignite-333: Add clear(K key) method to IgniteCache.
Date Tue, 10 Mar 2015 09:56:27 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-333 [created] def046797


#ignite-333: Add clear(K key) 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/4a072f4b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/4a072f4b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/4a072f4b

Branch: refs/heads/ignite-333
Commit: 4a072f4b638234f36136f17c92f9a42add619acf
Parents: 314bf52
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Tue Mar 10 12:42:49 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Tue Mar 10 12:42:49 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     | 23 ++++++++++++++++++++
 .../processors/cache/IgniteCacheProxy.java      | 14 ++++++++++++
 2 files changed, 37 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a072f4b/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 195a304..21bf907 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -377,6 +377,29 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K,
V>, IgniteAsyncS
     @IgniteAsyncSupported
     @Override public void clear();
 
+    /**
+     * Clears an 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.
+     *
+     * @param key Key to clear.
+     * @return {@code True} if entry was successfully cleared from cache, {@code false}
+     * if entry was in use at the time of this method invocation and could not be
+     * cleared.
+     */
+    public boolean clear(K key);
+
     /** {@inheritDoc} */
     @IgniteAsyncSupported
     @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor,
Object... arguments);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4a072f4b/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 d1439b9..8470a8c 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,6 +1061,20 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
     }
 
     /** {@inheritDoc} */
+    @Override public boolean clear(K key) {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            return delegate.clearLocally(key);
+        }
+        finally {
+            gate.leave(prev);
+
+            return false;
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public <T> T invoke(K key, EntryProcessor<K, V, T> entryProcessor,
Object... args)
         throws EntryProcessorException {
         try {


Mime
View raw message