ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [09/22] ignite git commit: IGNITE-2944: .NET: Implemented operations with near cache on IIgnite interface. This closes #625.
Date Thu, 28 Apr 2016 11:29:09 GMT
IGNITE-2944: .NET: Implemented operations with near cache on IIgnite interface. This closes #625.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/0460a35d
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/0460a35d
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/0460a35d

Branch: refs/heads/ignite-2523-1-resp
Commit: 0460a35de25dba2ad4379c1b5e0f58ade93188af
Parents: 47b1b7f
Author: Pavel Tupitsyn <ptupitsyn@gridgain.com>
Authored: Wed Apr 27 11:30:17 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Apr 27 11:30:17 2016 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |   2 +
 .../platform/PlatformNoopProcessor.java         |  10 +
 .../processors/platform/PlatformProcessor.java  |  19 ++
 .../platform/PlatformProcessorImpl.java         |  41 +++-
 .../utils/PlatformConfigurationUtils.java       |  93 ++++++++-
 .../cpp/common/include/ignite/common/exports.h  |   2 +
 .../cpp/common/include/ignite/common/java.h     |   5 +
 .../platforms/cpp/common/project/vs/module.def  |   2 +
 modules/platforms/cpp/common/src/exports.cpp    |   8 +
 modules/platforms/cpp/common/src/java.cpp       |  30 +++
 .../Apache.Ignite.Core.Tests.csproj             |   1 +
 .../Cache/CacheConfigurationTest.cs             |  49 +++++
 .../Cache/CacheNearTest.cs                      | 188 +++++++++++++++++++
 .../dotnet/Apache.Ignite.Core.Tests/app.config  |   4 +
 .../Apache.Ignite.Core.csproj                   |   5 +
 .../Cache/Configuration/CacheConfiguration.cs   |  15 ++
 .../Configuration/NearCacheConfiguration.cs     |  75 ++++++++
 .../Cache/Eviction/EvictionPolicyBase.cs        | 126 +++++++++++++
 .../Cache/Eviction/FifoEvictionPolicy.cs        |  39 ++++
 .../Cache/Eviction/IEvictionPolicy.cs           |  32 ++++
 .../Cache/Eviction/LruEvictionPolicy.cs         |  39 ++++
 .../dotnet/Apache.Ignite.Core/IIgnite.cs        |  42 +++++
 .../dotnet/Apache.Ignite.Core/Impl/Ignite.cs    |  62 ++++++
 .../Apache.Ignite.Core/Impl/IgniteProxy.cs      |  25 +++
 .../Impl/Unmanaged/IgniteJniNativeMethods.cs    |   6 +
 .../Impl/Unmanaged/UnmanagedUtils.cs            |  32 ++++
 26 files changed, 948 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 07542de..ed392c2 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -544,6 +544,8 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
     }
 
     /**
+     * Sets the near cache configuration to use on all cache nodes.
+     *
      * @param nearCfg Near cache configuration.
      * @return {@code this} for chaining.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
index 06988ee..155981c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformNoopProcessor.java
@@ -160,4 +160,14 @@ public class PlatformNoopProcessor extends GridProcessorAdapter implements Platf
     @Override public PlatformTarget atomicReference(String name, long memPtr, boolean create) throws IgniteException {
         return null;
     }
+
+    /** {@inheritDoc} */
+    @Override public PlatformTarget createNearCache(@Nullable String cacheName, long memPtr) {
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlatformTarget getOrCreateNearCache(@Nullable String cacheName, long memPtr) {
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
index 2d51c69..cca29d8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessor.java
@@ -233,4 +233,23 @@ public interface PlatformProcessor extends GridProcessor {
      * @param memPtr Stream to write data to.
      */
     public void getIgniteConfiguration(long memPtr);
+
+    /**
+     * Starts a near cache on local node if cache was previously started.
+     *
+     * @param cacheName Cache name.
+     * @param memPtr Pointer to a stream with near cache config. 0 for default config.
+     * @return Cache.
+     */
+    public PlatformTarget createNearCache(@Nullable String cacheName, long memPtr);
+
+    /**
+     * Gets existing near cache with the given name or creates a new one.
+     *
+     * @param cacheName Cache name.
+     * @param memPtr Pointer to a stream with near cache config. 0 for default config.
+     * @return Cache.
+     */
+    public PlatformTarget getOrCreateNearCache(@Nullable String cacheName, long memPtr);
+
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
index bcdd91d..e294735 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformProcessorImpl.java
@@ -24,6 +24,7 @@ import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.configuration.PlatformConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
@@ -263,7 +264,9 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
         BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
         CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
 
-        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().createCache(cfg);
+        IgniteCacheProxy cache = reader.readBoolean()
+            ? (IgniteCacheProxy)ctx.grid().createCache(cfg, PlatformConfigurationUtils.readNearConfiguration(reader))
+            : (IgniteCacheProxy)ctx.grid().createCache(cfg);
 
         return new PlatformCache(platformCtx, cache.keepBinary(), false);
     }
@@ -273,7 +276,10 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
         BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
         CacheConfiguration cfg = PlatformConfigurationUtils.readCacheConfiguration(reader);
 
-        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg);
+        IgniteCacheProxy cache = reader.readBoolean()
+            ? (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg,
+                    PlatformConfigurationUtils.readNearConfiguration(reader))
+            : (IgniteCacheProxy)ctx.grid().getOrCreateCache(cfg);
 
         return new PlatformCache(platformCtx, cache.keepBinary(), false);
     }
@@ -408,6 +414,37 @@ public class PlatformProcessorImpl extends GridProcessorAdapter implements Platf
         stream.synchronize();
     }
 
+    /** {@inheritDoc} */
+    @Override public PlatformTarget createNearCache(@Nullable String cacheName, long memPtr) {
+        NearCacheConfiguration cfg = getNearCacheConfiguration(memPtr);
+
+        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().createNearCache(cacheName, cfg);
+
+        return new PlatformCache(platformCtx, cache.keepBinary(), false);
+    }
+
+    /** {@inheritDoc} */
+    @Override public PlatformTarget getOrCreateNearCache(@Nullable String cacheName, long memPtr) {
+        NearCacheConfiguration cfg = getNearCacheConfiguration(memPtr);
+
+        IgniteCacheProxy cache = (IgniteCacheProxy)ctx.grid().getOrCreateNearCache(cacheName, cfg);
+
+        return new PlatformCache(platformCtx, cache.keepBinary(), false);
+    }
+
+    /**
+     * Gets the near cache config.
+     *
+     * @param memPtr Memory pointer.
+     * @return Near config.
+     */
+    private NearCacheConfiguration getNearCacheConfiguration(long memPtr) {
+        assert memPtr != 0;
+
+        BinaryRawReaderEx reader = platformCtx.reader(platformCtx.memory().get(memPtr));
+        return PlatformConfigurationUtils.readNearConfiguration(reader);
+    }
+
     /**
      * Internal store initialization routine.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
index 51c7c6c..9d7f957 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java
@@ -28,10 +28,14 @@ import org.apache.ignite.cache.CacheWriteSynchronizationMode;
 import org.apache.ignite.cache.QueryEntity;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.cache.QueryIndexType;
+import org.apache.ignite.cache.eviction.EvictionPolicy;
+import org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy;
+import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy;
 import org.apache.ignite.configuration.AtomicConfiguration;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
 import org.apache.ignite.configuration.TransactionConfiguration;
 import org.apache.ignite.internal.binary.*;
 import org.apache.ignite.platform.dotnet.PlatformDotNetBinaryConfiguration;
@@ -163,10 +167,86 @@ import java.util.Map;
             ccfg.setQueryEntities(entities);
         }
 
+        if (in.readBoolean())
+            ccfg.setNearConfiguration(readNearConfiguration(in));
+
         return ccfg;
     }
 
     /**
+     * Reads the near config.
+     *
+     * @param in Stream.
+     * @return NearCacheConfiguration.
+     */
+    public static NearCacheConfiguration readNearConfiguration(BinaryRawReader in) {
+        NearCacheConfiguration cfg = new NearCacheConfiguration();
+        cfg.setNearStartSize(in.readInt());
+
+        byte plcTyp = in.readByte();
+
+        switch (plcTyp) {
+            case 0:
+                break;
+            case 1: {
+                FifoEvictionPolicy p = new FifoEvictionPolicy();
+                p.setBatchSize(in.readInt());
+                p.setMaxSize(in.readInt());
+                p.setMaxMemorySize(in.readLong());
+                cfg.setNearEvictionPolicy(p);
+                break;
+            }
+            case 2: {
+                LruEvictionPolicy p = new LruEvictionPolicy();
+                p.setBatchSize(in.readInt());
+                p.setMaxSize(in.readInt());
+                p.setMaxMemorySize(in.readLong());
+                cfg.setNearEvictionPolicy(p);
+                break;
+            }
+            default:
+                assert false;
+        }
+
+        return cfg;
+    }
+
+    /**
+     * Reads the near config.
+     *
+     * @param out Stream.
+     * @param cfg NearCacheConfiguration.
+     */
+    @SuppressWarnings("TypeMayBeWeakened")
+    public static void writeNearConfiguration(BinaryRawWriter out, NearCacheConfiguration cfg) {
+        assert cfg != null;
+
+        out.writeInt(cfg.getNearStartSize());
+
+        EvictionPolicy p = cfg.getNearEvictionPolicy();
+
+        if (p instanceof FifoEvictionPolicy) {
+            out.writeByte((byte)1);
+
+            FifoEvictionPolicy p0 = (FifoEvictionPolicy)p;
+            out.writeInt(p0.getBatchSize());
+            out.writeInt(p0.getMaxSize());
+            out.writeLong(p0.getMaxMemorySize());
+        }
+        else if (p instanceof LruEvictionPolicy) {
+            out.writeByte((byte)2);
+
+            LruEvictionPolicy p0 = (LruEvictionPolicy)p;
+            out.writeInt(p0.getBatchSize());
+            out.writeInt(p0.getMaxSize());
+            out.writeLong(p0.getMaxMemorySize());
+        }
+        else {
+            out.writeByte((byte)0);
+        }
+    }
+
+    /**
      * Reads the query entity.
      *
      * @param in Stream.
@@ -469,8 +549,7 @@ import java.util.Map;
 
         Collection<QueryEntity> qryEntities = ccfg.getQueryEntities();
 
-        if (qryEntities != null)
-        {
+        if (qryEntities != null) {
             writer.writeInt(qryEntities.size());
 
             for (QueryEntity e : qryEntities)
@@ -478,6 +557,16 @@ import java.util.Map;
         }
         else
             writer.writeInt(0);
+
+        NearCacheConfiguration nearCfg = ccfg.getNearConfiguration();
+
+        if (nearCfg != null) {
+            writer.writeBoolean(true);
+
+            writeNearConfiguration(writer, nearCfg);
+        }
+        else
+            writer.writeBoolean(false);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/cpp/common/include/ignite/common/exports.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/exports.h b/modules/platforms/cpp/common/include/ignite/common/exports.h
index 6f2049d..c62b365 100644
--- a/modules/platforms/cpp/common/include/ignite/common/exports.h
+++ b/modules/platforms/cpp/common/include/ignite/common/exports.h
@@ -38,6 +38,8 @@ extern "C" {
     void* IGNITE_CALL IgniteProcessorGetOrCreateCache(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long long memPtr);
     void* IGNITE_CALL IgniteProcessorGetOrCreateCacheFromConfig(gcj::JniContext* ctx, void* obj, long long memPtr);
+    void* IGNITE_CALL IgniteProcessorCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr);
+    void* IGNITE_CALL IgniteProcessorGetOrCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr);
     void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorAffinity(gcj::JniContext* ctx, void* obj, char* name);
     void* IGNITE_CALL IgniteProcessorDataStreamer(gcj::JniContext* ctx, void* obj, char* name, bool keepPortable);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/cpp/common/include/ignite/common/java.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/java.h b/modules/platforms/cpp/common/include/ignite/common/java.h
index 4b79665..f2007cb 100644
--- a/modules/platforms/cpp/common/include/ignite/common/java.h
+++ b/modules/platforms/cpp/common/include/ignite/common/java.h
@@ -305,6 +305,8 @@ namespace ignite
                 jmethodID m_PlatformProcessor_getOrCreateCache;
                 jmethodID m_PlatformProcessor_createCacheFromConfig;
                 jmethodID m_PlatformProcessor_getOrCreateCacheFromConfig;
+                jmethodID m_PlatformProcessor_createNearCache;
+                jmethodID m_PlatformProcessor_getOrCreateNearCache;
                 jmethodID m_PlatformProcessor_destroyCache;
                 jmethodID m_PlatformProcessor_affinity;
                 jmethodID m_PlatformProcessor_dataStreamer;
@@ -519,6 +521,8 @@ namespace ignite
                 jobject ProcessorCreateCacheFromConfig(jobject obj, long long memPtr, JniErrorInfo* errInfo);
                 jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long long memPtr);
                 jobject ProcessorGetOrCreateCacheFromConfig(jobject obj, long long memPtr, JniErrorInfo* errInfo);
+                jobject ProcessorCreateNearCache(jobject obj, const char* name, long long memPtr);
+                jobject ProcessorGetOrCreateNearCache(jobject obj, const char* name, long long memPtr);
                 void ProcessorDestroyCache(jobject obj, const char* name);
                 void ProcessorDestroyCache(jobject obj, const char* name, JniErrorInfo* errInfo);
                 jobject ProcessorAffinity(jobject obj, const char* name);
@@ -665,6 +669,7 @@ namespace ignite
                 jobject LocalToGlobal(JNIEnv* env, jobject obj);
                 jobject ProcessorCache0(jobject proc, const char* name, jmethodID mthd, JniErrorInfo* errInfo);
                 jobject ProcessorCacheFromConfig0(jobject proc, long long memPtr, jmethodID mthd, JniErrorInfo* errInfo);
+                jobject ProcessorGetOrCreateNearCache0(jobject obj, const char* name, long long memPtr, jmethodID methodID);
             };
 
             JNIEXPORT jlong JNICALL JniCacheStoreCreate(JNIEnv *env, jclass cls, jlong envPtr, jlong memPtr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/cpp/common/project/vs/module.def
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/module.def b/modules/platforms/cpp/common/project/vs/module.def
index 21a4994..57e58f3 100644
--- a/modules/platforms/cpp/common/project/vs/module.def
+++ b/modules/platforms/cpp/common/project/vs/module.def
@@ -130,3 +130,5 @@ IgniteAtomicSequenceClose @127
 IgniteProcessorAtomicReference @128
 IgniteAtomicReferenceIsClosed @129
 IgniteAtomicReferenceClose @130
+IgniteProcessorCreateNearCache @131
+IgniteProcessorGetOrCreateNearCache @132

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/cpp/common/src/exports.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/exports.cpp b/modules/platforms/cpp/common/src/exports.cpp
index 93fd337..0d951b6 100644
--- a/modules/platforms/cpp/common/src/exports.cpp
+++ b/modules/platforms/cpp/common/src/exports.cpp
@@ -74,6 +74,14 @@ extern "C" {
         return ctx->ProcessorGetOrCreateCacheFromConfig(static_cast<jobject>(obj), memPtr);
     }
 
+    void* IGNITE_CALL IgniteProcessorCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr) {
+        return ctx->ProcessorCreateNearCache(static_cast<jobject>(obj), name, memPtr);
+    }
+
+    void* IGNITE_CALL IgniteProcessorGetOrCreateNearCache(gcj::JniContext* ctx, void* obj, char* name, long long memPtr) {
+        return ctx->ProcessorGetOrCreateNearCache(static_cast<jobject>(obj), name, memPtr);
+    }
+
     void IGNITE_CALL IgniteProcessorDestroyCache(gcj::JniContext* ctx, void* obj, char* name) {
         ctx->ProcessorDestroyCache(static_cast<jobject>(obj), name);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/cpp/common/src/java.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/java.cpp b/modules/platforms/cpp/common/src/java.cpp
index c029038..081a606 100644
--- a/modules/platforms/cpp/common/src/java.cpp
+++ b/modules/platforms/cpp/common/src/java.cpp
@@ -193,6 +193,8 @@ namespace ignite
             JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE = JniMethod("getOrCreateCache", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG = JniMethod("createCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG = JniMethod("getOrCreateCacheFromConfig", "(J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+            JniMethod M_PLATFORM_PROCESSOR_CREATE_NEAR_CACHE = JniMethod("createNearCache", "(Ljava/lang/String;J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
+            JniMethod M_PLATFORM_PROCESSOR_GET_OR_CREATE_NEAR_CACHE = JniMethod("getOrCreateNearCache", "(Ljava/lang/String;J)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_DESTROY_CACHE = JniMethod("destroyCache", "(Ljava/lang/String;)V", false);
             JniMethod M_PLATFORM_PROCESSOR_AFFINITY = JniMethod("affinity", "(Ljava/lang/String;)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
             JniMethod M_PLATFORM_PROCESSOR_DATA_STREAMER = JniMethod("dataStreamer", "(Ljava/lang/String;Z)Lorg/apache/ignite/internal/processors/platform/PlatformTarget;", false);
@@ -661,6 +663,8 @@ namespace ignite
                 m_PlatformProcessor_getOrCreateCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE);
                 m_PlatformProcessor_createCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_CACHE_FROM_CONFIG);
                 m_PlatformProcessor_getOrCreateCacheFromConfig = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_CACHE_FROM_CONFIG);
+                m_PlatformProcessor_createNearCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_CREATE_NEAR_CACHE);
+                m_PlatformProcessor_getOrCreateNearCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_GET_OR_CREATE_NEAR_CACHE);
                 m_PlatformProcessor_destroyCache = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DESTROY_CACHE);
                 m_PlatformProcessor_affinity = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_AFFINITY);
                 m_PlatformProcessor_dataStreamer = FindMethod(env, c_PlatformProcessor, M_PLATFORM_PROCESSOR_DATA_STREAMER);
@@ -1283,6 +1287,32 @@ namespace ignite
                 return ProcessorCacheFromConfig0(obj, memPtr, jvm->GetMembers().m_PlatformProcessor_getOrCreateCacheFromConfig, errInfo);
             }
 
+            jobject JniContext::ProcessorCreateNearCache(jobject obj, const char* name, long long memPtr)
+            {
+                return ProcessorGetOrCreateNearCache0(obj, name, memPtr, jvm->GetMembers().m_PlatformProcessor_createNearCache);
+            }
+
+            jobject JniContext::ProcessorGetOrCreateNearCache(jobject obj, const char* name, long long memPtr)
+            {
+                return ProcessorGetOrCreateNearCache0(obj, name, memPtr, jvm->GetMembers().m_PlatformProcessor_getOrCreateNearCache);
+            }
+
+            jobject JniContext::ProcessorGetOrCreateNearCache0(jobject obj, const char* name, long long memPtr, jmethodID methodID)
+            {
+                JNIEnv* env = Attach();
+
+                jstring name0 = name != NULL ? env->NewStringUTF(name) : NULL;
+
+                jobject cache = env->CallObjectMethod(obj, methodID, name0, memPtr);
+
+                if (name0)
+                    env->DeleteLocalRef(name0);
+
+                ExceptionCheck(env);
+
+                return LocalToGlobal(env, cache);
+            }
+
             jobject JniContext::ProcessorAffinity(jobject obj, const char* name) {
                 JNIEnv* env = Attach();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
index de21765..002fa26 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Apache.Ignite.Core.Tests.csproj
@@ -58,6 +58,7 @@
     <Compile Include="Cache\CacheAffinityFieldTest.cs" />
     <Compile Include="Cache\CacheConfigurationTest.cs" />
     <Compile Include="Cache\CacheDynamicStartTest.cs" />
+    <Compile Include="Cache\CacheNearTest.cs" />
     <Compile Include="Cache\CacheTestAsyncWrapper.cs" />
     <Compile Include="Cache\CacheAbstractTest.cs" />
     <Compile Include="Cache\CacheAffinityTest.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
index bc259e5..d474f38 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheConfigurationTest.cs
@@ -22,6 +22,7 @@ namespace Apache.Ignite.Core.Tests.Cache
     using System.Linq;
     using Apache.Ignite.Core.Binary;
     using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Eviction;
     using Apache.Ignite.Core.Cache.Store;
     using Apache.Ignite.Core.Common;
     using NUnit.Framework;
@@ -237,6 +238,44 @@ namespace Apache.Ignite.Core.Tests.Cache
             Assert.AreEqual(x.WriteBehindFlushSize, y.WriteBehindFlushSize);
 
             AssertConfigsAreEqual(x.QueryEntities, y.QueryEntities);
+            AssertConfigsAreEqual(x.NearConfiguration, y.NearConfiguration);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(NearCacheConfiguration x, NearCacheConfiguration y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.NearStartSize, y.NearStartSize);
+
+            AssertConfigsAreEqual(x.EvictionPolicy, y.EvictionPolicy);
+        }
+
+        /// <summary>
+        /// Asserts that two configurations have the same properties.
+        /// </summary>
+        private static void AssertConfigsAreEqual(IEvictionPolicy x, IEvictionPolicy y)
+        {
+            if (x == null)
+            {
+                Assert.IsNull(y);
+                return;
+            }
+
+            Assert.AreEqual(x.GetType(), y.GetType());
+
+            var px = (EvictionPolicyBase) x;
+            var py = (EvictionPolicyBase) y;
+
+            Assert.AreEqual(px.BatchSize, py.BatchSize);
+            Assert.AreEqual(px.MaxSize, py.MaxSize);
+            Assert.AreEqual(px.MaxMemorySize, py.MaxMemorySize);
         }
 
         /// <summary>
@@ -460,6 +499,16 @@ namespace Apache.Ignite.Core.Tests.Cache
                             }
                         }
                     }
+                },
+                NearConfiguration = new NearCacheConfiguration
+                {
+                    NearStartSize = 456,
+                    EvictionPolicy = new LruEvictionPolicy
+                    {
+                        MaxSize = 25,
+                        MaxMemorySize = 2500,
+                        BatchSize = 3
+                    }
                 }
             };
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheNearTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheNearTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheNearTest.cs
new file mode 100644
index 0000000..f5a1337
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheNearTest.cs
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Tests.Cache
+{
+    using Apache.Ignite.Core.Cache;
+    using Apache.Ignite.Core.Cache.Configuration;
+    using Apache.Ignite.Core.Cache.Eviction;
+    using Apache.Ignite.Core.Events;
+    using NUnit.Framework;
+
+    /// <summary>
+    /// Near cache test.
+    /// </summary>
+    public class CacheNearTest : IEventListener<CacheEvent>
+    {
+        /** */
+        private IIgnite _grid;
+
+        /** */
+        private volatile CacheEvent _lastEvent;
+
+        /// <summary>
+        /// Fixture set up.
+        /// </summary>
+        [TestFixtureSetUp]
+        public void FixtureSetUp()
+        {
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                CacheConfiguration = new[]
+                {
+                    new CacheConfiguration
+                    {
+                        NearConfiguration = new NearCacheConfiguration
+                        {
+                            EvictionPolicy = new FifoEvictionPolicy {MaxSize = 5}
+                        }
+                    }
+                },
+                IncludedEventTypes = new[] { EventType.CacheEntryCreated }
+            };
+
+            _grid = Ignition.Start(cfg);
+        }
+
+        /// <summary>
+        /// Fixture tear down.
+        /// </summary>
+        [TestFixtureTearDown]
+        public void FixtureTearDown()
+        {
+            Ignition.StopAll(true);
+        }
+
+        /// <summary>
+        /// Tests the existing near cache.
+        /// </summary>
+        [Test]
+        public void TestExistingNearCache()
+        {
+            var cache = _grid.GetCache<int, string>(null);
+
+            cache[1] = "1";
+
+            var nearCache = _grid.GetOrCreateNearCache<int, string>(null, new NearCacheConfiguration());
+            Assert.AreEqual("1", nearCache[1]);
+
+            // GetOrCreate when exists
+            nearCache = _grid.GetOrCreateNearCache<int, string>(null, new NearCacheConfiguration());
+            Assert.AreEqual("1", nearCache[1]);
+        }
+
+        /// <summary>
+        /// Tests the created near cache.
+        /// </summary>
+        [Test]
+        public void TestCreateNearCache()
+        {
+            const string cacheName = "dyn_cache";
+
+            var cache = _grid.CreateCache<int, string>(cacheName);
+            cache[1] = "1";
+
+            var nearCache = _grid.CreateNearCache<int, string>(cacheName, new NearCacheConfiguration());
+            Assert.AreEqual("1", nearCache[1]);
+
+            // Create when exists
+            nearCache = _grid.CreateNearCache<int, string>(cacheName, new NearCacheConfiguration());
+            Assert.AreEqual("1", nearCache[1]);
+        }
+
+        /// <summary>
+        /// Tests near cache on the client node.
+        /// </summary>
+        [Test]
+        public void TestCreateNearCacheOnClientNode()
+        {
+            const string cacheName = "client_cache";
+
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                ClientMode = true,
+                GridName = "clientGrid"
+            };
+
+            using (var clientGrid = Ignition.Start(cfg))
+            {
+                clientGrid.CreateCache<int, string>(cacheName);
+
+                // Near cache can't be started on client node
+                Assert.Throws<CacheException>(
+                    () => clientGrid.CreateNearCache<int, string>(cacheName, new NearCacheConfiguration()));
+            }
+        }
+
+        /// <summary>
+        /// Tests near cache on the client node.
+        /// </summary>
+        [Test]
+        public void TestCreateCacheWithNearConfigOnClientNode()
+        {
+            const string cacheName = "client_with_near_cache";
+
+            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
+            {
+                ClientMode = true,
+                GridName = "clientGrid",
+                IncludedEventTypes = new[] {EventType.CacheEntryCreated}
+            };
+
+            using (var clientGrid = Ignition.Start(cfg))
+            {
+                var cache = clientGrid.CreateCache<int, string>(new CacheConfiguration(cacheName), 
+                    new NearCacheConfiguration());
+
+                AssertCacheIsNear(cache);
+
+                cache[1] = "1";
+                Assert.AreEqual("1", cache[1]);
+
+                var cache2 = clientGrid.GetOrCreateCache<int, string>(new CacheConfiguration(cacheName),
+                    new NearCacheConfiguration());
+
+                Assert.AreEqual("1", cache2[1]);
+            }
+        }
+
+        /// <summary>
+        /// Asserts the cache is near.
+        /// </summary>
+        private void AssertCacheIsNear(ICache<int, string> cache)
+        {
+            var events = cache.Ignite.GetEvents();
+            events.LocalListen(this, EventType.CacheEntryCreated);
+
+            _lastEvent = null;
+            cache[-1] = "test";
+
+            TestUtils.WaitForCondition(() => _lastEvent != null, 500);
+            Assert.IsNotNull(_lastEvent);
+            Assert.IsTrue(_lastEvent.IsNear);
+
+            events.StopLocalListen(this, EventType.CacheEntryCreated);
+        }
+
+        /** <inheritdoc /> */
+        public bool Invoke(CacheEvent evt)
+        {
+            _lastEvent = evt;
+            return true;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
index 2e72ce4..1df48bf 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/app.config
@@ -23,6 +23,10 @@
         <section name="igniteConfiguration2" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
     </configSections>
 
+    <runtime>
+        <gcServer enabled="true"/>
+    </runtime>
+
     <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" gridName="myGrid1">
         <discoverySpi type="TcpDiscoverySpi">
             <ipFinder type="TcpDiscoveryStaticIpFinder">

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
index 19d370a..8d56227 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Apache.Ignite.Core.csproj
@@ -92,6 +92,7 @@
     <Compile Include="Cache\CacheException.cs" />
     <Compile Include="Cache\CachePartialUpdateException.cs" />
     <Compile Include="Cache\CachePeekMode.cs" />
+    <Compile Include="Cache\Configuration\NearCacheConfiguration.cs" />
     <Compile Include="DataStructures\Configuration\AtomicConfiguration.cs" />
     <Compile Include="Cache\Configuration\QueryAlias.cs" />
     <Compile Include="Cache\Configuration\QueryTextFieldAttribute.cs" />
@@ -100,6 +101,10 @@
     <Compile Include="Cache\Event\ICacheEntryEventFilter.cs" />
     <Compile Include="Cache\Event\ICacheEntryEventListener.cs" />
     <Compile Include="Cache\Event\Package-Info.cs" />
+    <Compile Include="Cache\Eviction\EvictionPolicyBase.cs" />
+    <Compile Include="Cache\Eviction\FifoEvictionPolicy.cs" />
+    <Compile Include="Cache\Eviction\IEvictionPolicy.cs" />
+    <Compile Include="Cache\Eviction\LruEvictionPolicy.cs" />
     <Compile Include="Cache\Expiry\ExpiryPolicy.cs" />
     <Compile Include="Cache\Expiry\IExpiryPolicy.cs" />
     <Compile Include="Cache\Expiry\Package-Info.cs" />

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
index ba509fc..e5fcdb1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/CacheConfiguration.cs
@@ -267,6 +267,8 @@ namespace Apache.Ignite.Core.Cache.Configuration
 
             var count = reader.ReadInt();
             QueryEntities = count == 0 ? null : Enumerable.Range(0, count).Select(x => new QueryEntity(reader)).ToList();
+
+            NearConfiguration = reader.ReadBoolean() ? new NearCacheConfiguration(reader) : null;
         }
 
         /// <summary>
@@ -329,6 +331,14 @@ namespace Apache.Ignite.Core.Cache.Configuration
             }
             else
                 writer.WriteInt(0);
+
+            if (NearConfiguration != null)
+            {
+                writer.WriteBoolean(true);
+                NearConfiguration.Write(writer);
+            }
+            else
+                writer.WriteBoolean(false);
         }
 
         /// <summary>
@@ -633,5 +643,10 @@ namespace Apache.Ignite.Core.Cache.Configuration
         /// </summary>
         [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public ICollection<QueryEntity> QueryEntities { get; set; }
+
+        /// <summary>
+        /// Gets or sets the near cache configuration.
+        /// </summary>
+        public NearCacheConfiguration NearConfiguration { get; set; }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/NearCacheConfiguration.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/NearCacheConfiguration.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/NearCacheConfiguration.cs
new file mode 100644
index 0000000..dc9219f
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Configuration/NearCacheConfiguration.cs
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Configuration
+{
+    using System.ComponentModel;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Eviction;
+
+    /// <summary>
+    /// Defines near cache configuration.
+    /// <para />
+    /// Distributed cache can also be fronted by a Near cache, which is a smaller local cache that stores most 
+    /// recently or most frequently accessed data. 
+    /// Just like with a partitioned cache, the user can control the size of the near cache and its eviction policies. 
+    /// </summary>
+    public class NearCacheConfiguration
+    {
+        /// <summary> Initial default near cache size. </summary>
+        public const int DefaultNearStartSize = CacheConfiguration.DefaultStartSize / 4;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="NearCacheConfiguration"/> class.
+        /// </summary>
+        public NearCacheConfiguration()
+        {
+            NearStartSize = DefaultNearStartSize;
+        }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="NearCacheConfiguration"/> class.
+        /// </summary>
+        internal NearCacheConfiguration(IBinaryRawReader reader)
+        {
+            NearStartSize = reader.ReadInt();
+            EvictionPolicy = EvictionPolicyBase.Read(reader);
+        }
+
+        /// <summary>
+        /// Writes to the specified writer.
+        /// </summary>
+        internal void Write(IBinaryRawWriter writer)
+        {
+            writer.WriteInt(NearStartSize);
+            EvictionPolicyBase.Write(writer, EvictionPolicy);
+        }
+
+        /// <summary>
+        /// Gets or sets the eviction policy.
+        /// Null value means disabled evictions.
+        /// </summary>
+        public IEvictionPolicy EvictionPolicy { get; set; }
+
+        /// <summary>
+        /// Gets or sets the initial cache size for near cache which will be used 
+        /// to pre-create internal hash table after start.
+        /// </summary>
+        [DefaultValue(DefaultNearStartSize)]
+        public int NearStartSize { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/EvictionPolicyBase.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/EvictionPolicyBase.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/EvictionPolicyBase.cs
new file mode 100644
index 0000000..ee533b1
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/EvictionPolicyBase.cs
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Eviction
+{
+    using System;
+    using System.ComponentModel;
+    using Apache.Ignite.Core.Binary;
+    using Apache.Ignite.Core.Cache.Configuration;
+
+    /// <summary>
+    /// Base class for predefined eviction policies.
+    /// </summary>
+    public abstract class EvictionPolicyBase : IEvictionPolicy
+    {
+        /// <summary> Default batch cache size. </summary>
+        public const int DefaultBatchSize = 1;
+        
+        /// <summary> Default max cache size. </summary>
+        public const int DefaultMaxSize = CacheConfiguration.DefaultCacheSize;
+
+        /// <summary> Default max cache size in bytes. </summary>
+        public const long DefaultMaxMemorySize = 0;
+
+        /// <summary>
+        /// Gets or sets the size of the eviction batch.
+        /// Batch eviction is enabled only if maximum memory limit isn't set (<see cref="MaxMemorySize"/> == 0).
+        /// </summary>
+        [DefaultValue(DefaultBatchSize)]
+        public int BatchSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum allowed cache size (entry count).
+        /// 0 for unlimited.
+        /// </summary>
+        [DefaultValue(DefaultMaxSize)]
+        public int MaxSize { get; set; }
+
+        /// <summary>
+        /// Gets or sets the maximum allowed cache size in bytes.
+        /// 0 for unlimited.
+        /// </summary>
+        [DefaultValue(DefaultMaxMemorySize)]
+        public long MaxMemorySize { get; set; }
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="EvictionPolicyBase"/> class.
+        /// </summary>
+        internal EvictionPolicyBase()
+        {
+            BatchSize = DefaultBatchSize;
+            MaxSize = DefaultMaxSize;
+            MaxMemorySize = DefaultMaxMemorySize;
+        }
+        
+        /// <summary>
+        /// Writes to the specified writer.
+        /// </summary>
+        internal static void Write(IBinaryRawWriter writer, IEvictionPolicy policy)
+        {
+            if (policy == null)
+            {
+                writer.WriteByte(0);
+                return;
+            }
+
+            var p = policy as EvictionPolicyBase;
+
+            if (p == null)
+            {
+                throw new NotSupportedException(
+                    string.Format("Unsupported Eviction Policy: {0}. Only predefined eviction policy types " +
+                                  "are supported: {1}, {2}", policy.GetType(), typeof (LruEvictionPolicy),
+                        typeof (FifoEvictionPolicy)));
+            }
+
+            writer.WriteByte(p is FifoEvictionPolicy ? (byte) 1 : (byte) 2);
+
+            writer.WriteInt(p.BatchSize);
+            writer.WriteInt(p.MaxSize);
+            writer.WriteLong(p.MaxMemorySize);
+        }
+
+        /// <summary>
+        /// Reads an instance.
+        /// </summary>
+        internal static EvictionPolicyBase Read(IBinaryRawReader reader)
+        {
+            EvictionPolicyBase p;
+
+            switch (reader.ReadByte())
+            {
+                case 0:
+                    return null;
+                case 1:
+                    p = new FifoEvictionPolicy();
+                    break;
+                case 2:
+                    p = new LruEvictionPolicy();
+                    break;
+                default:
+                    throw new InvalidOperationException("Unsupported eviction policy.");
+            }
+
+            p.BatchSize = reader.ReadInt();
+            p.MaxSize = reader.ReadInt();
+            p.MaxMemorySize = reader.ReadLong();
+
+            return p;
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/FifoEvictionPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/FifoEvictionPolicy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/FifoEvictionPolicy.cs
new file mode 100644
index 0000000..9c8dc2a
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/FifoEvictionPolicy.cs
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Eviction
+{
+    /// <summary>
+    /// Eviction policy based on First In First Out (FIFO) algorithm with batch eviction support.
+    /// <para />
+    /// The eviction starts in the following cases: 
+    /// The cache size becomes { @code batchSize }
+    /// elements greater than the maximum size;
+    /// The size of cache entries in bytes becomes greater than the maximum memory size;
+    /// The size of cache entry calculates as sum of key size and value size.
+    /// <para />
+    /// Note: Batch eviction is enabled only if maximum memory limit isn't set.
+    /// <para />
+    /// This implementation is very efficient since it does not create any additional
+    /// table-like data structures. The FIFO ordering information is
+    /// maintained by attaching ordering metadata to cache entries.
+    /// </summary>
+    public class FifoEvictionPolicy : EvictionPolicyBase
+    {
+        // No-op.
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/IEvictionPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/IEvictionPolicy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/IEvictionPolicy.cs
new file mode 100644
index 0000000..44d8d79
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/IEvictionPolicy.cs
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Eviction
+{
+    using System.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Represents a cache eviction policy.
+    /// Only predefined implementations are supported now: 
+    /// <see cref="LruEvictionPolicy"/>, <see cref="FifoEvictionPolicy"/>.
+    /// </summary>
+    [SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces")]
+    public interface IEvictionPolicy
+    {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/LruEvictionPolicy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/LruEvictionPolicy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/LruEvictionPolicy.cs
new file mode 100644
index 0000000..b3b9566
--- /dev/null
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Cache/Eviction/LruEvictionPolicy.cs
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.Ignite.Core.Cache.Eviction
+{
+    /// <summary>
+    /// Eviction policy based on Least Recently Used (LRU) algorithm with batch eviction support.
+    /// <para />
+    /// The eviction starts in the following cases: 
+    /// The cache size becomes { @code batchSize }
+    /// elements greater than the maximum size;
+    /// The size of cache entries in bytes becomes greater than the maximum memory size;
+    /// The size of cache entry calculates as sum of key size and value size.
+    /// <para />
+    /// Note: Batch eviction is enabled only if maximum memory limit isn't set.
+    /// <para />
+    /// This implementation is very efficient since it does not create any additional
+    /// table-like data structures. The LRU ordering information is
+    /// maintained by attaching ordering metadata to cache entries.
+    /// </summary>
+    public class LruEvictionPolicy : EvictionPolicyBase
+    {
+        // No-op.
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
index 12ea09e..428c1a8 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/IIgnite.cs
@@ -103,6 +103,17 @@ namespace Apache.Ignite.Core
         ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration);
 
         /// <summary>
+        /// Gets existing cache with the given name or creates new one using provided configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="configuration">Cache configuration.</param>
+        /// /// <param name="nearConfiguration">Near cache configuration for client.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration, 
+            NearCacheConfiguration nearConfiguration);
+
+        /// <summary>
         /// Dynamically starts new cache using template configuration.
         /// </summary>
         /// <typeparam name="TK">Cache key type.</typeparam>
@@ -121,6 +132,17 @@ namespace Apache.Ignite.Core
         ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration);
 
         /// <summary>
+        /// Dynamically starts new cache using provided configuration.
+        /// </summary>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <param name="configuration">Cache configuration.</param>
+        /// <param name="nearConfiguration">Near cache configuration for client.</param>
+        /// <returns>Existing or newly created cache.</returns>
+        ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration, 
+            NearCacheConfiguration nearConfiguration);
+
+        /// <summary>
         /// Destroys dynamically created (with <see cref="CreateCache{TK,TV}(string)"/> or 
         /// <see cref="GetOrCreateCache{TK,TV}(string)"/>) cache.
         /// </summary>
@@ -224,5 +246,25 @@ namespace Apache.Ignite.Core
         /// </summary>
         [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Semantics.")]
         IgniteConfiguration GetConfiguration();
+
+        /// <summary>
+        /// Starts a near cache on local node if cache with specified was previously started.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <param name="configuration">The configuration.</param>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <returns>Near cache instance.</returns>
+        ICache<TK, TV> CreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration);
+
+        /// <summary>
+        /// Gets existing near cache with the given name or creates a new one.
+        /// </summary>
+        /// <param name="name">The name.</param>
+        /// <param name="configuration">The configuration.</param>
+        /// <typeparam name="TK">Cache key type.</typeparam>
+        /// <typeparam name="TV">Cache value type.</typeparam>
+        /// <returns>Near cache instance.</returns>
+        ICache<TK, TV> GetOrCreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration);
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
index 1735fb8..b84ff29 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Ignite.cs
@@ -368,6 +368,13 @@ namespace Apache.Ignite.Core.Impl
         /** <inheritdoc /> */
         public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration)
         {
+            return GetOrCreateCache<TK, TV>(configuration, null);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration, 
+            NearCacheConfiguration nearConfiguration)
+        {
             IgniteArgumentCheck.NotNull(configuration, "configuration");
 
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
@@ -376,6 +383,14 @@ namespace Apache.Ignite.Core.Impl
 
                 configuration.Write(writer);
 
+                if (nearConfiguration != null)
+                {
+                    writer.WriteBoolean(true);
+                    nearConfiguration.Write(writer);
+                }
+                else
+                    writer.WriteBoolean(false);
+
                 stream.SynchronizeOutput();
 
                 return Cache<TK, TV>(UU.ProcessorGetOrCreateCache(_proc, stream.MemoryPointer));
@@ -391,6 +406,13 @@ namespace Apache.Ignite.Core.Impl
         /** <inheritdoc /> */
         public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration)
         {
+            return CreateCache<TK, TV>(configuration, null);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration, 
+            NearCacheConfiguration nearConfiguration)
+        {
             IgniteArgumentCheck.NotNull(configuration, "configuration");
 
             using (var stream = IgniteManager.Memory.Allocate().GetStream())
@@ -399,6 +421,14 @@ namespace Apache.Ignite.Core.Impl
 
                 configuration.Write(writer);
 
+                if (nearConfiguration != null)
+                {
+                    writer.WriteBoolean(true);
+                    nearConfiguration.Write(writer);
+                }
+                else
+                    writer.WriteBoolean(false);
+
                 stream.SynchronizeOutput();
 
                 return Cache<TK, TV>(UU.ProcessorCreateCache(_proc, stream.MemoryPointer));
@@ -580,6 +610,38 @@ namespace Apache.Ignite.Core.Impl
             }
         }
 
+        /** <inheritdoc /> */
+        public ICache<TK, TV> CreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
+        {
+            return GetOrCreateNearCache0<TK, TV>(name, configuration, UU.ProcessorCreateNearCache);
+        }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
+        {
+            return GetOrCreateNearCache0<TK, TV>(name, configuration, UU.ProcessorGetOrCreateNearCache);
+        }
+
+        /// <summary>
+        /// Gets or creates near cache.
+        /// </summary>
+        private ICache<TK, TV> GetOrCreateNearCache0<TK, TV>(string name, NearCacheConfiguration configuration,
+            Func<IUnmanagedTarget, string, long, IUnmanagedTarget> func)
+        {
+            IgniteArgumentCheck.NotNull(configuration, "configuration");
+
+            using (var stream = IgniteManager.Memory.Allocate().GetStream())
+            {
+                var writer = Marshaller.StartMarshal(stream);
+
+                configuration.Write(writer);
+
+                stream.SynchronizeOutput();
+
+                return Cache<TK, TV>(func(_proc, name, stream.MemoryPointer));
+            }
+        }
+
         /// <summary>
         /// Gets internal projection.
         /// </summary>

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
index 0aa55fb..a767077 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/IgniteProxy.cs
@@ -240,6 +240,12 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> GetOrCreateCache<TK, TV>(CacheConfiguration configuration, NearCacheConfiguration nearConfiguration)
+        {
+            return _ignite.GetOrCreateCache<TK, TV>(configuration, nearConfiguration);
+        }
+
+        /** <inheritdoc /> */
         public ICache<TK, TV> CreateCache<TK, TV>(string name)
         {
             return _ignite.CreateCache<TK, TV>(name);
@@ -250,6 +256,14 @@ namespace Apache.Ignite.Core.Impl
         {
             return _ignite.CreateCache<TK, TV>(configuration);
         }
+
+        /** <inheritdoc /> */
+        public ICache<TK, TV> CreateCache<TK, TV>(CacheConfiguration configuration, NearCacheConfiguration nearConfiguration)
+        {
+            return _ignite.CreateCache<TK, TV>(configuration, nearConfiguration);
+        }
+
+        /** <inheritdoc /> */
         public void DestroyCache(string name)
         {
             _ignite.DestroyCache(name);
@@ -347,6 +361,17 @@ namespace Apache.Ignite.Core.Impl
         }
 
         /** <inheritdoc /> */
+        public ICache<TK, TV> CreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
+        {
+            return _ignite.CreateNearCache<TK, TV>(name, configuration);
+        }
+
+        public ICache<TK, TV> GetOrCreateNearCache<TK, TV>(string name, NearCacheConfiguration configuration)
+        {
+            return _ignite.GetOrCreateNearCache<TK, TV>(name, configuration);
+        }
+
+        /** <inheritdoc /> */
         public IAtomicSequence GetAtomicSequence(string name, long initialValue, bool create)
         {
             return _ignite.GetAtomicSequence(name, initialValue, create);

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
index 28eb208..2603841 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/IgniteJniNativeMethods.cs
@@ -61,6 +61,12 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateCacheFromConfig")]
         public static extern void* ProcessorGetOrCreateCacheFromConfig(void* ctx, void* obj, long memPtr);
 
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorCreateNearCache")]
+        public static extern void* ProcessorCreateNearCache(void* ctx, void* obj, sbyte* name, long memPtr);
+
+        [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorGetOrCreateNearCache")]
+        public static extern void* ProcessorGetOrCreateNearCache(void* ctx, void* obj, sbyte* name, long memPtr);
+
         [DllImport(IgniteUtils.FileIgniteJniDll, EntryPoint = "IgniteProcessorDestroyCache")]
         public static extern void ProcessorDestroyCache(void* ctx, void* obj, sbyte* name);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/0460a35d/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
index afe46a8..f8b5256 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Unmanaged/UnmanagedUtils.cs
@@ -180,6 +180,38 @@ namespace Apache.Ignite.Core.Impl.Unmanaged
             return target.ChangeTarget(res);
         }
 
+        internal static IUnmanagedTarget ProcessorCreateNearCache(IUnmanagedTarget target, string name, long memPtr)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = JNI.ProcessorCreateNearCache(target.Context, target.Target, name0, memPtr);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
+        internal static IUnmanagedTarget ProcessorGetOrCreateNearCache(IUnmanagedTarget target, string name, long memPtr)
+        {
+            sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);
+
+            try
+            {
+                void* res = JNI.ProcessorGetOrCreateNearCache(target.Context, target.Target, name0, memPtr);
+
+                return target.ChangeTarget(res);
+            }
+            finally
+            {
+                Marshal.FreeHGlobal(new IntPtr(name0));
+            }
+        }
+
         internal static void ProcessorDestroyCache(IUnmanagedTarget target, string name)
         {
             sbyte* name0 = IgniteUtils.StringToUtf8Unmanaged(name);


Mime
View raw message