http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index 1ffed64..2a79198 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -36,7 +36,7 @@ import java.util.concurrent.*;
 /**
  * Internal API for cache entry ({@code 'Ex'} stands for extended).
  */
-public interface GridCacheEntryEx<K, V> {
+public interface GridCacheEntryEx {
     /**
      * @return Memory size.
      * @throws IgniteCheckedException If failed.
@@ -85,7 +85,7 @@ public interface GridCacheEntryEx<K, V> {
     /**
      * @return Context.
      */
-    public GridCacheContext<K, V> context();
+    public <K, V> GridCacheContext<K, V> context();
 
     /**
      * @return Partition ID.
@@ -100,17 +100,17 @@ public interface GridCacheEntryEx<K, V> {
     /**
      * @return Key.
      */
-    public K key();
+    public KeyCacheObject key();
 
     /**
      * @return Transaction key.
      */
-    public IgniteTxKey<K> txKey();
+    public IgniteTxKey txKey();
 
     /**
      * @return Value.
      */
-    public V rawGet();
+    public CacheObject rawGet();
 
     /**
      * @param tmp If {@code true} can return temporary instance which is valid 
while entry lock is held,
@@ -119,7 +119,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Value (unmarshalled if needed).
      * @throws IgniteCheckedException If failed.
      */
-    public V rawGetOrUnmarshal(boolean tmp) throws IgniteCheckedException;
+    public CacheObject rawGetOrUnmarshal(boolean tmp) throws 
IgniteCheckedException;
 
     /**
      * @return {@code True} if has value or value bytes.
@@ -131,21 +131,21 @@ public interface GridCacheEntryEx<K, V> {
      * @param ttl Time to live.
      * @return Old value.
      */
-    public V rawPut(V val, long ttl);
+    public CacheObject rawPut(CacheObject val, long ttl);
 
     /**
      * Wraps this map entry into cache entry.
      *
      * @return Wrapped entry.
      */
-    public Cache.Entry<K, V> wrap();
+    public <K, V> Cache.Entry<K, V> wrap();
 
     /**
      * Wraps entry to an entry with lazy value get.
      *
      * @return Entry.
      */
-    public Cache.Entry<K, V> wrapLazyValue();
+    public <K, V> Cache.Entry<K, V> wrapLazyValue();
 
     /**
      * Wraps this map entry into cache entry for filter evaluation inside 
entry lock.
@@ -153,18 +153,18 @@ public interface GridCacheEntryEx<K, V> {
      * @return Wrapped entry.
      * @throws IgniteCheckedException If failed.
      */
-    public Cache.Entry<K, V> wrapFilterLocked() throws IgniteCheckedException;
+    public <K, V> Cache.Entry<K, V> wrapFilterLocked() throws 
IgniteCheckedException;
 
     /**
      * @return Entry which is safe to pass into eviction policy.
      */
-    public EvictableEntry<K, V> wrapEviction();
+    public <K, V> EvictableEntry<K, V> wrapEviction();
 
     /**
      * @return Entry which holds key and version (no value, since entry
      *      is intended to be used in sync evictions checks).
      */
-    public CacheVersionedEntryImpl<K, V> wrapVersioned();
+    public <K, V> CacheVersionedEntryImpl<K, V> wrapVersioned();
 
     /**
      * @return Not-null version if entry is obsolete.
@@ -192,7 +192,7 @@ public interface GridCacheEntryEx<K, V> {
     /**
      * @return Entry info.
      */
-    @Nullable public GridCacheEntryInfo<K, V> info();
+    @Nullable public GridCacheEntryInfo info();
 
     /**
      * Invalidates this entry.
@@ -212,7 +212,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If swap could not be released.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public boolean invalidate(@Nullable IgnitePredicate<Cache.Entry<K, V>>[] 
filter)
+    public <K, V> boolean invalidate(@Nullable IgnitePredicate<Cache.Entry<K, 
V>>[] filter)
         throws GridCacheEntryRemovedException, IgniteCheckedException;
 
     /**
@@ -223,7 +223,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If operation failed.
      * @return {@code true} if entry was not being used and could be removed.
      */
-    public boolean compact(@Nullable IgnitePredicate<Cache.Entry<K, V>>[] 
filter)
+    public <K, V> boolean compact(@Nullable IgnitePredicate<Cache.Entry<K, 
V>>[] filter)
         throws GridCacheEntryRemovedException, IgniteCheckedException;
 
     /**
@@ -233,7 +233,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return {@code True} if entry could be evicted.
      * @throws IgniteCheckedException In case of error.
      */
-    public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
+    public <K, V> boolean evictInternal(boolean swap, GridCacheVersion 
obsoleteVer,
         @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter) throws 
IgniteCheckedException;
 
     /**
@@ -244,7 +244,8 @@ public interface GridCacheEntryEx<K, V> {
      * @return Swap entry if this entry was marked obsolete, {@code null} if 
entry was not evicted.
      * @throws IgniteCheckedException If failed.
      */
-    public GridCacheBatchSwapEntry<K, V> evictInBatchInternal(GridCacheVersion 
obsoleteVer) throws IgniteCheckedException;
+    // TODO IGNITE-51
+    public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion 
obsoleteVer) throws IgniteCheckedException;
 
     /**
      * This method should be called each time entry is marked obsolete
@@ -303,7 +304,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws GridCacheEntryRemovedException If entry was removed.
      * @throws GridCacheFilterFailedException If filter failed.
      */
-    @Nullable public V innerGet(@Nullable IgniteInternalTx<K, V> tx,
+    @Nullable public CacheObject innerGet(@Nullable IgniteInternalTx tx,
         boolean readSwap,
         boolean readThrough,
         boolean failFast,
@@ -324,7 +325,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If reload failed.
      * @throws GridCacheEntryRemovedException If entry has been removed.
      */
-    @Nullable public V innerReload() throws IgniteCheckedException,
+    @Nullable public CacheObject innerReload() throws IgniteCheckedException,
         GridCacheEntryRemovedException;
 
     /**
@@ -350,11 +351,11 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If storing value failed.
      * @throws GridCacheEntryRemovedException If entry has been removed.
      */
-    public GridCacheUpdateTxResult<V> innerSet(
-        @Nullable IgniteInternalTx<K, V> tx,
+    public <K, V> GridCacheUpdateTxResult<CacheObject> innerSet(
+        @Nullable IgniteInternalTx tx,
         UUID evtNodeId,
         UUID affNodeId,
-        @Nullable V val,
+        @Nullable CacheObject val,
         @Nullable byte[] valBytes,
         boolean writeThrough,
         boolean retval,
@@ -389,8 +390,8 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If remove failed.
      * @throws GridCacheEntryRemovedException If entry has been removed.
      */
-    public GridCacheUpdateTxResult<V> innerRemove(
-        @Nullable IgniteInternalTx<K, V> tx,
+    public <K, V> GridCacheUpdateTxResult<CacheObject> innerRemove(
+        @Nullable IgniteInternalTx tx,
         UUID evtNodeId,
         UUID affNodeId,
         boolean writeThrough,
@@ -438,7 +439,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If update failed.
      * @throws GridCacheEntryRemovedException If entry is obsolete.
      */
-    public GridCacheUpdateAtomicResult<K, V> innerUpdate(
+    public GridCacheUpdateAtomicResult innerUpdate(
         GridCacheVersion ver,
         UUID evtNodeId,
         UUID affNodeId,
@@ -453,7 +454,7 @@ public interface GridCacheEntryEx<K, V> {
         boolean metrics,
         boolean primary,
         boolean checkVer,
-        @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter,
+        @Nullable IgnitePredicate<Cache.Entry<Object, Object>>[] filter,
         GridDrType drType,
         long conflictTtl,
         long conflictExpireTime,
@@ -484,7 +485,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If update failed.
      * @throws GridCacheEntryRemovedException If entry is obsolete.
      */
-    public GridTuple3<Boolean, V, EntryProcessorResult<Object>> 
innerUpdateLocal(
+    public <K, V> GridTuple3<Boolean, CacheObject, 
EntryProcessorResult<Object>> innerUpdateLocal(
         GridCacheVersion ver,
         GridCacheOperation op,
         @Nullable Object writeObj,
@@ -511,7 +512,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If failed to remove from swap.
      * @return {@code True} if entry was not being used, passed the filter and 
could be removed.
      */
-    public boolean clear(GridCacheVersion ver, boolean readers,
+    public <K, V> boolean clear(GridCacheVersion ver, boolean readers,
         @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter) throws 
IgniteCheckedException;
 
     /**
@@ -524,7 +525,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws GridCacheEntryRemovedException If this entry is obsolete.
      * @throws GridDistributedLockCancelledException If lock has been 
cancelled.
      */
-    public boolean tmLock(IgniteInternalTx<K, V> tx, long timeout) throws 
GridCacheEntryRemovedException,
+    public boolean tmLock(IgniteInternalTx tx, long timeout) throws 
GridCacheEntryRemovedException,
         GridDistributedLockCancelledException;
 
     /**
@@ -533,7 +534,7 @@ public interface GridCacheEntryEx<K, V> {
      * @param tx Cache transaction.
      * @throws GridCacheEntryRemovedException If this entry has been removed 
from cache.
      */
-    public abstract void txUnlock(IgniteInternalTx<K, V> tx) throws 
GridCacheEntryRemovedException;
+    public abstract void txUnlock(IgniteInternalTx tx) throws 
GridCacheEntryRemovedException;
 
     /**
      * @param ver Removes lock.
@@ -594,7 +595,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Value.
      * @throws GridCacheEntryRemovedException If entry has been removed.
      */
-    @Nullable public V peek(GridCachePeekMode mode, 
IgnitePredicate<Cache.Entry<K, V>>... filter)
+    @Nullable public <K, V> CacheObject peek(GridCachePeekMode mode, 
IgnitePredicate<Cache.Entry<K, V>>... filter)
         throws GridCacheEntryRemovedException;
 
     /**
@@ -609,7 +610,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws GridCacheEntryRemovedException If entry has been removed.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public V peek(boolean heap,
+    @Nullable public CacheObject peek(boolean heap,
         boolean offheap,
         boolean swap,
         long topVer,
@@ -624,8 +625,8 @@ public interface GridCacheEntryEx<K, V> {
      * @return Value.
      * @throws GridCacheEntryRemovedException If entry has been removed.
      */
-    @Nullable public V peek(Collection<GridCachePeekMode> modes, 
IgnitePredicate<Cache.Entry<K, V>>... filter)
-        throws GridCacheEntryRemovedException;
+    @Nullable public <K, V> CacheObject peek(Collection<GridCachePeekMode> 
modes,
+        IgnitePredicate<Cache.Entry<K, V>>... filter) throws 
GridCacheEntryRemovedException;
 
     /**
      * Peeks into entry without loading value or updating statistics.
@@ -637,7 +638,8 @@ public interface GridCacheEntryEx<K, V> {
      * @throws GridCacheFilterFailedException If {@code failFast} is {@code 
true} and
      *      filter didn't pass.
      */
-    @Nullable public V peekFailFast(GridCachePeekMode mode, 
IgnitePredicate<Cache.Entry<K, V>>... filter)
+    @Nullable public <K, V> CacheObject peekFailFast(GridCachePeekMode mode,
+        IgnitePredicate<Cache.Entry<K, V>>... filter)
         throws GridCacheEntryRemovedException, GridCacheFilterFailedException;
 
     /**
@@ -651,8 +653,10 @@ public interface GridCacheEntryEx<K, V> {
      * @throws GridCacheFilterFailedException If filter failed.
      */
     @SuppressWarnings({"RedundantTypeArguments"})
-    @Nullable public GridTuple<V> peek0(boolean failFast, GridCachePeekMode 
mode,
-        @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter, @Nullable 
IgniteInternalTx<K, V> tx)
+    @Nullable public <K, V> GridTuple<CacheObject> peek0(boolean failFast,
+        GridCachePeekMode mode,
+        @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter,
+        @Nullable IgniteInternalTx tx)
         throws GridCacheEntryRemovedException, GridCacheFilterFailedException, 
IgniteCheckedException;
 
     /**
@@ -666,7 +670,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If poke operation failed.
      * @throws GridCacheEntryRemovedException if entry was unexpectedly 
removed.
      */
-    public V poke(V val) throws GridCacheEntryRemovedException, 
IgniteCheckedException;
+    public CacheObject poke(CacheObject val) throws 
GridCacheEntryRemovedException, IgniteCheckedException;
 
     /**
      * Sets new value if current version is <tt>0</tt>
@@ -683,8 +687,14 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException In case of error.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public boolean initialValue(V val, @Nullable byte[] valBytes, 
GridCacheVersion ver, long ttl, long expireTime,
-        boolean preload, long topVer, GridDrType drType) throws 
IgniteCheckedException, GridCacheEntryRemovedException;
+    public boolean initialValue(CacheObject val,
+        @Nullable byte[] valBytes,
+        GridCacheVersion ver,
+        long ttl,
+        long expireTime,
+        boolean preload,
+        long topVer,
+        GridDrType drType) throws IgniteCheckedException, 
GridCacheEntryRemovedException;
 
     /**
      * Sets new value if current version is <tt>0</tt> using swap entry data.
@@ -696,7 +706,8 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException In case of error.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public boolean initialValue(K key, GridCacheSwapEntry<V> unswapped)
+    // TODO IGNITE-51
+    public boolean initialValue(KeyCacheObject key, GridCacheSwapEntry 
unswapped)
         throws IgniteCheckedException, GridCacheEntryRemovedException;
 
     /**
@@ -705,7 +716,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Versioned entry.
      * @throws IgniteCheckedException In case of error.
      */
-    public GridCacheVersionedEntryEx<K, V> versionedEntry() throws 
IgniteCheckedException;
+    public <K, V> GridCacheVersionedEntryEx<K, V> versionedEntry() throws 
IgniteCheckedException;
 
     /**
      * Sets new value if passed in version matches the current version
@@ -718,7 +729,7 @@ public interface GridCacheEntryEx<K, V> {
      * @throws IgniteCheckedException If index could not be updated.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public boolean versionedValue(V val, @Nullable GridCacheVersion curVer, 
@Nullable GridCacheVersion newVer)
+    public boolean versionedValue(CacheObject val, @Nullable GridCacheVersion 
curVer, @Nullable GridCacheVersion newVer)
         throws IgniteCheckedException, GridCacheEntryRemovedException;
 
     /**
@@ -758,7 +769,8 @@ public interface GridCacheEntryEx<K, V> {
      * @return {@code True} if locked either locally or by thread.
      * @throws GridCacheEntryRemovedException If removed.
      */
-    public boolean lockedLocallyByIdOrThread(GridCacheVersion lockVer, long 
threadId) throws GridCacheEntryRemovedException;
+    public boolean lockedLocallyByIdOrThread(GridCacheVersion lockVer, long 
threadId)
+        throws GridCacheEntryRemovedException;
 
     /**
      *
@@ -822,7 +834,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Local candidate.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    @Nullable public GridCacheMvccCandidate<K> localCandidate(long threadId) 
throws GridCacheEntryRemovedException;
+    @Nullable public GridCacheMvccCandidate localCandidate(long threadId) 
throws GridCacheEntryRemovedException;
 
     /**
      * Gets all local candidates.
@@ -831,7 +843,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return All local candidates.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public Collection<GridCacheMvccCandidate<K>> localCandidates(@Nullable 
GridCacheVersion... exclude)
+    public Collection<GridCacheMvccCandidate> localCandidates(@Nullable 
GridCacheVersion... exclude)
         throws GridCacheEntryRemovedException;
 
     /**
@@ -840,7 +852,7 @@ public interface GridCacheEntryEx<K, V> {
      * @param exclude Exclude version.
      * @return All remote versions minus the excluded ones, if any.
      */
-    public Collection<GridCacheMvccCandidate<K>> 
remoteMvccSnapshot(GridCacheVersion... exclude);
+    public Collection<GridCacheMvccCandidate> 
remoteMvccSnapshot(GridCacheVersion... exclude);
 
     /**
      * Gets lock candidate for given lock ID.
@@ -849,7 +861,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Lock candidate for given ID.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    @Nullable public GridCacheMvccCandidate<K> candidate(GridCacheVersion ver) 
throws GridCacheEntryRemovedException;
+    @Nullable public GridCacheMvccCandidate candidate(GridCacheVersion ver) 
throws GridCacheEntryRemovedException;
 
     /**
      * @param nodeId Node ID.
@@ -857,14 +869,14 @@ public interface GridCacheEntryEx<K, V> {
      * @return Candidate.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    @Nullable public GridCacheMvccCandidate<K> candidate(UUID nodeId, long 
threadId)
+    @Nullable public GridCacheMvccCandidate candidate(UUID nodeId, long 
threadId)
         throws GridCacheEntryRemovedException;
 
     /**
      * @return Local owner.
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    @Nullable public GridCacheMvccCandidate<K> localOwner() throws 
GridCacheEntryRemovedException;
+    @Nullable public GridCacheMvccCandidate localOwner() throws 
GridCacheEntryRemovedException;
 
     /**
      * @param keyBytes Key bytes.
@@ -934,7 +946,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Value.
      * @throws IgniteCheckedException If failed to read from swap storage.
      */
-    @Nullable public V unswap() throws IgniteCheckedException;
+    @Nullable public CacheObject unswap() throws IgniteCheckedException;
 
     /**
      * Unswap ignoring flags.
@@ -944,7 +956,7 @@ public interface GridCacheEntryEx<K, V> {
      * @return Value.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public V unswap(boolean ignoreFlags, boolean needVal) throws 
IgniteCheckedException;
+    @Nullable public CacheObject unswap(boolean ignoreFlags, boolean needVal) 
throws IgniteCheckedException;
 
     /**
      * Tests whether or not given metadata is set.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
index b35ae98..9faa8f5 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
@@ -29,14 +29,14 @@ import java.io.*;
 /**
  * Entry information that gets passed over wire.
  */
-public class GridCacheEntryInfo<K, V> implements Externalizable {
+public class GridCacheEntryInfo implements Externalizable {
     /** */
     private static final long serialVersionUID = 0L;
 
     /** Cache key. */
     @GridToStringInclude
     @GridDirectTransient
-    private K key;
+    private KeyCacheObject key;
 
     /** Cache ID. */
     private int cacheId;
@@ -49,7 +49,7 @@ public class GridCacheEntryInfo<K, V> implements 
Externalizable {
 
     /** Cache value. */
     @GridDirectTransient
-    private V val;
+    private CacheObject val;
 
     /** Value bytes. */
     private byte[] valBytes;
@@ -89,60 +89,32 @@ public class GridCacheEntryInfo<K, V> implements 
Externalizable {
     /**
      * @param key Entry key.
      */
-    public void key(K key) {
+    public void key(KeyCacheObject key) {
         this.key = key;
     }
 
     /**
      * @return Entry key.
      */
-    public K key() {
+    public KeyCacheObject key() {
         return key;
     }
 
     /**
-     * @return Key bytes.
-     */
-    public byte[] keyBytes() {
-        return keyBytes;
-    }
-
-    /**
-     * @param keyBytes Key bytes.
-     */
-    public void keyBytes(byte[] keyBytes) {
-        this.keyBytes = keyBytes;
-    }
-
-    /**
      * @return Entry value.
      */
-    public V value() {
+    public CacheObject value() {
         return val;
     }
 
     /**
      * @param val Entry value.
      */
-    public void value(V val) {
+    public void value(CacheObject val) {
         this.val = val;
     }
 
     /**
-     * @return Value bytes.
-     */
-    public byte[] valueBytes() {
-        return valBytes;
-    }
-
-    /**
-     * @param valBytes Value bytes.
-     */
-    public void valueBytes(byte[] valBytes) {
-        this.valBytes = valBytes;
-    }
-
-    /**
      * @return Expire time.
      */
     public long expireTime() {
@@ -217,7 +189,7 @@ public class GridCacheEntryInfo<K, V> implements 
Externalizable {
      * @param ldr Loader.
      * @throws IgniteCheckedException If failed.
      */
-    public void unmarshalValue(GridCacheContext<K, V> ctx, ClassLoader ldr) 
throws IgniteCheckedException {
+    public void unmarshalValue(GridCacheContext<?, ?> ctx, ClassLoader ldr) 
throws IgniteCheckedException {
         if (val == null && valBytes != null)
             val = ctx.marshaller().unmarshal(valBytes, ldr);
     }
@@ -226,7 +198,7 @@ public class GridCacheEntryInfo<K, V> implements 
Externalizable {
      * @param ctx Cache context.
      * @throws IgniteCheckedException In case of error.
      */
-    public void marshal(GridCacheSharedContext<K, V> ctx) throws 
IgniteCheckedException {
+    public void marshal(GridCacheSharedContext<?, ?> ctx) throws 
IgniteCheckedException {
         boolean depEnabled = ctx.gridDeploy().enabled();
 
         boolean valIsByteArr = val != null && val instanceof byte[];

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
index e1ff9c0..fb8d124 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
@@ -33,7 +33,7 @@ import static org.apache.ignite.events.EventType.*;
 /**
  * Cache event manager.
  */
-public class GridCacheEventManager<K, V> extends GridCacheManagerAdapter<K, V> 
{
+public class GridCacheEventManager extends GridCacheManagerAdapter {
     /** Local node ID. */
     private UUID locNodeId;
 
@@ -75,10 +75,31 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param cloClsName Closure class name.
      * @param taskName Task name.
      */
-    public void addEvent(int part, K key, IgniteInternalTx tx, @Nullable 
GridCacheMvccCandidate<K> owner,
-        int type, @Nullable V newVal, boolean hasNewVal, @Nullable V oldVal, 
boolean hasOldVal, UUID subjId,
-        String cloClsName, String taskName) {
-        addEvent(part, key, locNodeId, tx, owner, type, newVal, hasNewVal, 
oldVal, hasOldVal, subjId, cloClsName,
+    public void addEvent(int part,
+        KeyCacheObject key,
+        IgniteInternalTx tx,
+        @Nullable GridCacheMvccCandidate owner,
+        int type,
+        @Nullable CacheObject newVal,
+        boolean hasNewVal,
+        @Nullable CacheObject oldVal,
+        boolean hasOldVal,
+        UUID subjId,
+        String cloClsName,
+        String taskName)
+    {
+        addEvent(part,
+            key,
+            locNodeId,
+            tx,
+            owner,
+            type,
+            newVal,
+            hasNewVal,
+            oldVal,
+            hasOldVal,
+            subjId,
+            cloClsName,
             taskName);
     }
 
@@ -97,11 +118,32 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param cloClsName Closure class name.
      * @param taskName Task name.
      */
-    public void addEvent(int part, K key, UUID nodeId, IgniteInternalTx tx, 
GridCacheMvccCandidate<K> owner,
-        int type, V newVal, boolean hasNewVal, V oldVal, boolean hasOldVal, 
UUID subjId, String cloClsName,
-        String taskName) {
-        addEvent(part, key, nodeId, tx == null ? null : tx.xid(), owner == 
null ? null : owner.version(), type,
-            newVal, hasNewVal, oldVal, hasOldVal, subjId, cloClsName, 
taskName);
+    public void addEvent(int part,
+        KeyCacheObject key,
+        UUID nodeId,
+        IgniteInternalTx tx,
+        GridCacheMvccCandidate owner,
+        int type,
+        CacheObject newVal,
+        boolean hasNewVal,
+        CacheObject oldVal,
+        boolean hasOldVal,
+        UUID subjId,
+        String cloClsName,
+        String taskName)
+    {
+        addEvent(part,
+            key,
+            nodeId, tx == null ? null : tx.xid(),
+            owner == null ? null : owner.version(),
+            type,
+            newVal,
+            hasNewVal,
+            oldVal,
+            hasOldVal,
+            subjId,
+            cloClsName,
+            taskName);
     }
 
     /**
@@ -118,13 +160,34 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param cloClsName Closure class name.
      * @param taskName Task name.
      */
-    public void addEvent(int part, K key, UUID evtNodeId, @Nullable 
GridCacheMvccCandidate<K> owner,
-        int type, @Nullable V newVal, boolean hasNewVal, V oldVal, boolean 
hasOldVal, UUID subjId, String cloClsName,
-        String taskName) {
+    public void addEvent(int part,
+        KeyCacheObject key,
+        UUID evtNodeId,
+        @Nullable GridCacheMvccCandidate owner,
+        int type,
+        @Nullable CacheObject newVal,
+        boolean hasNewVal,
+        CacheObject oldVal,
+        boolean hasOldVal,
+        UUID subjId,
+        String cloClsName,
+        String taskName)
+    {
         IgniteInternalTx tx = owner == null ? null : 
cctx.tm().tx(owner.version());
 
-        addEvent(part, key, evtNodeId, tx == null ? null : tx.xid(), owner == 
null ? null : owner.version(), type,
-            newVal, hasNewVal, oldVal, hasOldVal, subjId, cloClsName, 
taskName);
+        addEvent(part,
+            key,
+            evtNodeId,
+            tx == null ? null : tx.xid(),
+            owner == null ? null : owner.version(),
+            type,
+            newVal,
+            hasNewVal,
+            oldVal,
+            hasOldVal,
+            subjId,
+            cloClsName,
+            taskName);
     }
 
     /**
@@ -144,14 +207,14 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      */
     public void addEvent(
         int part,
-        K key,
+        KeyCacheObject key,
         UUID evtNodeId,
         @Nullable IgniteUuid xid,
         @Nullable Object lockId,
         int type,
-        @Nullable V newVal,
+        @Nullable CacheObject newVal,
         boolean hasNewVal,
-        @Nullable V oldVal,
+        @Nullable CacheObject oldVal,
         boolean hasOldVal,
         UUID subjId,
         @Nullable String cloClsName,
@@ -163,7 +226,7 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             LT.warn(log, null, "Added event without checking if event is 
recordable: " + U.gridEventName(type));
 
         // Events are not fired for internal entry.
-        if (!(key instanceof GridCacheInternal)) {
+        if (!key.internal()) {
             ClusterNode evtNode = cctx.discovery().node(evtNodeId);
 
             if (evtNode == null)
@@ -174,9 +237,23 @@ public class GridCacheEventManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                     "(try to increase topology history size configuration 
property of configured " +
                     "discovery SPI): " + evtNodeId);
 
-            cctx.gridEvents().record(new CacheEvent(cctx.name(), 
cctx.localNode(), evtNode,
-                "Cache event.", type, part, cctx.isNear(), key, xid, lockId, 
newVal, hasNewVal, oldVal, hasOldVal,
-                subjId, cloClsName, taskName));
+            cctx.gridEvents().record(new CacheEvent(cctx.name(),
+                cctx.localNode(),
+                evtNode,
+                "Cache event.",
+                type,
+                part,
+                cctx.isNear(),
+                key.value(cctx),
+                xid,
+                lockId,
+                newVal != null ? newVal.value(cctx) : null,
+                hasNewVal,
+                oldVal != null ? oldVal.value(cctx) : null,
+                hasOldVal,
+                subjId,
+                cloClsName,
+                taskName));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
index 23c1306..f88e3f0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionRequest.java
@@ -33,7 +33,7 @@ import java.util.*;
 /**
  * Cache eviction request.
  */
-public class GridCacheEvictionRequest<K, V> extends GridCacheMessage<K, V> 
implements GridCacheDeployable {
+public class GridCacheEvictionRequest extends GridCacheMessage implements 
GridCacheDeployable {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -43,7 +43,7 @@ public class GridCacheEvictionRequest<K, V> extends 
GridCacheMessage<K, V> imple
     /** Entries to clear from near and backup nodes. */
     @GridToStringInclude
     @GridDirectTransient
-    private Collection<GridTuple3<K, GridCacheVersion, Boolean>> entries;
+    private Collection<GridTuple3<KeyCacheObject, GridCacheVersion, Boolean>> 
entries;
 
     /** Serialized entries. */
     @GridToStringExclude
@@ -80,7 +80,7 @@ public class GridCacheEvictionRequest<K, V> extends 
GridCacheMessage<K, V> imple
 
     /** {@inheritDoc}
      * @param ctx*/
-    @Override public void prepareMarshal(GridCacheSharedContext<K, V> ctx) 
throws IgniteCheckedException {
+    @Override public void prepareMarshal(GridCacheSharedContext ctx) throws 
IgniteCheckedException {
         super.prepareMarshal(ctx);
 
         if (entries != null) {
@@ -92,7 +92,7 @@ public class GridCacheEvictionRequest<K, V> extends 
GridCacheMessage<K, V> imple
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, 
ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(GridCacheSharedContext ctx, 
ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
         if (entriesBytes != null)
@@ -109,7 +109,7 @@ public class GridCacheEvictionRequest<K, V> extends 
GridCacheMessage<K, V> imple
     /**
      * @return Entries - {{Key, Version, Boolean (near or not)}, ...}.
      */
-    Collection<GridTuple3<K, GridCacheVersion, Boolean>> entries() {
+    Collection<GridTuple3<KeyCacheObject, GridCacheVersion, Boolean>> 
entries() {
         return entries;
     }
 
@@ -127,7 +127,7 @@ public class GridCacheEvictionRequest<K, V> extends 
GridCacheMessage<K, V> imple
      * @param ver Entry version.
      * @param near {@code true} if key should be evicted from near cache.
      */
-    void addKey(K key, GridCacheVersion ver, boolean near) {
+    void addKey(KeyCacheObject key, GridCacheVersion ver, boolean near) {
         assert key != null;
         assert ver != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
index 1e8fe58..a8d45a5 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionResponse.java
@@ -30,7 +30,7 @@ import java.util.*;
 /**
  * Cache eviction response.
  */
-public class GridCacheEvictionResponse<K, V> extends GridCacheMessage<K, V> {
+public class GridCacheEvictionResponse extends GridCacheMessage {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -40,7 +40,7 @@ public class GridCacheEvictionResponse<K, V> extends 
GridCacheMessage<K, V> {
     /** Rejected keys. */
     @GridToStringInclude
     @GridDirectTransient
-    private Collection<K> rejectedKeys = new HashSet<>();
+    private Collection<KeyCacheObject> rejectedKeys = new HashSet<>();
 
     /** Serialized rejected keys. */
     @GridToStringExclude
@@ -78,14 +78,14 @@ public class GridCacheEvictionResponse<K, V> extends 
GridCacheMessage<K, V> {
 
     /** {@inheritDoc}
      * @param ctx*/
-    @Override public void prepareMarshal(GridCacheSharedContext<K, V> ctx) 
throws IgniteCheckedException {
+    @Override public void prepareMarshal(GridCacheSharedContext ctx) throws 
IgniteCheckedException {
         super.prepareMarshal(ctx);
 
         rejectedKeyBytes = marshalCollection(rejectedKeys, ctx);
     }
 
     /** {@inheritDoc} */
-    @Override public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, 
ClassLoader ldr) throws IgniteCheckedException {
+    @Override public void finishUnmarshal(GridCacheSharedContext ctx, 
ClassLoader ldr) throws IgniteCheckedException {
         super.finishUnmarshal(ctx, ldr);
 
         rejectedKeys = unmarshalCollection(rejectedKeyBytes, ctx, ldr);
@@ -101,7 +101,7 @@ public class GridCacheEvictionResponse<K, V> extends 
GridCacheMessage<K, V> {
     /**
      * @return Rejected keys.
      */
-    Collection<K> rejectedKeys() {
+    Collection<KeyCacheObject> rejectedKeys() {
         return rejectedKeys;
     }
 
@@ -110,7 +110,7 @@ public class GridCacheEvictionResponse<K, V> extends 
GridCacheMessage<K, V> {
      *
      * @param key Evicted key.
      */
-    void addRejected(K key) {
+    void addRejected(KeyCacheObject key) {
         assert key != null;
 
         rejectedKeys.add(key);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 18fce53..5688f0b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -55,7 +55,7 @@ import static 
org.apache.ignite.transactions.TransactionState.*;
  */
 @SuppressWarnings({
     "NonPrivateFieldAccessedInSynchronizedContext", "TooBroadScope", 
"FieldAccessedSynchronizedAndUnsynchronized"})
-public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K, 
V> {
+public abstract class GridCacheMapEntry implements GridCacheEntryEx {
     /** */
     private static final sun.misc.Unsafe UNSAFE = GridUnsafe.unsafe();
 
@@ -79,6 +79,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * <li>Each nested object should be analyzed in the same way as above.</li>
      * </ul>
      */
+    // TODO IGNITE-51.
     private static final int SIZE_OVERHEAD = 87 /*entry*/ + 32 /* version */;
 
     /** Static logger to avoid re-creation. Made static for test purpose. */
@@ -89,15 +90,15 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
     /** Cache registry. */
     @GridToStringExclude
-    protected final GridCacheContext<K, V> cctx;
+    protected final GridCacheContext<?, ?> cctx;
 
     /** Key. */
     @GridToStringInclude
-    protected final K key;
+    protected final KeyCacheObject key;
 
     /** Value. */
     @GridToStringInclude
-    protected V val;
+    protected CacheObject val;
 
     /** Start version. */
     @GridToStringInclude
@@ -109,30 +110,22 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
     /** Next entry in the linked list. */
     @GridToStringExclude
-    private volatile GridCacheMapEntry<K, V> next0;
+    private volatile GridCacheMapEntry next0;
 
     /** Next entry in the linked list. */
     @GridToStringExclude
-    private volatile GridCacheMapEntry<K, V> next1;
+    private volatile GridCacheMapEntry next1;
 
     /** Key hash code. */
     @GridToStringInclude
     private final int hash;
 
-    /** Key bytes. */
-    @GridToStringExclude
-    private volatile byte[] keyBytes;
-
-    /** Value bytes. */
-    @GridToStringExclude
-    protected byte[] valBytes;
-
     /** Off-heap value pointer. */
     private long valPtr;
 
     /** Extras */
     @GridToStringInclude
-    private GridCacheEntryExtras<K> extras;
+    private GridCacheEntryExtras extras;
 
     /**
      * Flags:
@@ -153,12 +146,12 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @param ttl Time to live.
      * @param hdrId Header id.
      */
-    protected GridCacheMapEntry(GridCacheContext<K, V> cctx, K key, int hash, 
V val,
-        GridCacheMapEntry<K, V> next, long ttl, int hdrId) {
+    protected GridCacheMapEntry(GridCacheContext<?, ?> cctx, KeyCacheObject 
key, int hash, CacheObject val,
+        GridCacheMapEntry next, long ttl, int hdrId) {
         log = U.logger(cctx.kernalContext(), logRef, GridCacheMapEntry.class);
 
         if (cctx.portableEnabled())
-            key = (K)cctx.kernalContext().portable().detachPortable(key);
+            key = 
(KeyCacheObject)cctx.kernalContext().portable().detachPortable(key);
 
         this.key = key;
         this.hash = hash;
@@ -167,7 +160,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
         ttlAndExpireTimeExtras(ttl, CU.toExpireTime(ttl));
 
         if (cctx.portableEnabled())
-            val = (V)cctx.kernalContext().portable().detachPortable(val);
+            val = 
(CacheObject)cctx.kernalContext().portable().detachPortable(val);
 
         synchronized (this) {
             value(val, null);
@@ -191,25 +184,25 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @param val Value to store.
      * @param valBytes Value bytes to store.
      */
-    protected void value(@Nullable V val, @Nullable byte[] valBytes) {
+    protected void value(@Nullable CacheObject val, @Nullable byte[] valBytes) 
{
         assert Thread.holdsLock(this);
 
         // In case we deal with IGFS cache, count updated data
         if (cctx.cache().isIgfsDataCache() && 
cctx.kernalContext().igfsHelper().isIgfsBlockKey(key())) {
-            int newSize = valueLength((byte[])val, valBytes != null ? 
GridCacheValueBytes.marshaled(valBytes) :
-                GridCacheValueBytes.nil());
-            int oldSize = valueLength((byte[])this.val, this.val == null ? 
valueBytesUnlocked() :
-                GridCacheValueBytes.nil());
-
-            int delta = newSize - oldSize;
-
-            if (delta != 0 && !cctx.isNear())
-                cctx.cache().onIgfsDataSizeChanged(delta);
+// TODO IGNITE-51.
+//            int newSize = valueLength((byte[])val, valBytes != null ? 
GridCacheValueBytes.marshaled(valBytes) :
+//                GridCacheValueBytes.nil());
+//            int oldSize = valueLength((byte[])this.val, this.val == null ? 
valueBytesUnlocked() :
+//                GridCacheValueBytes.nil());
+//
+//            int delta = newSize - oldSize;
+//
+//            if (delta != 0 && !cctx.isNear())
+//                cctx.cache().onIgfsDataSizeChanged(delta);
         }
 
         if (!isOffHeapValuesOnly()) {
             this.val = val;
-            this.valBytes = isStoreValueBytes() ? valBytes : null;
 
             valPtr = 0;
         }
@@ -235,12 +228,13 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                 assert mem != null;
 
                 if (val != null || valBytes != null) {
-                    boolean valIsByteArr = val instanceof byte[];
-
-                    if (valBytes == null && !valIsByteArr)
-                        valBytes = CU.marshal(cctx.shared(), val);
-
-                    valPtr = mem.putOffHeap(valPtr, valIsByteArr ? (byte[])val 
: valBytes, valIsByteArr);
+// TODO IGNITE-51.
+//                    boolean valIsByteArr = val instanceof byte[];
+//
+//                    if (valBytes == null && !valIsByteArr)
+//                        valBytes = CU.marshal(cctx.shared(), val);
+//
+//                    valPtr = mem.putOffHeap(valPtr, valIsByteArr ? 
(byte[])val : valBytes, valIsByteArr);
                 }
                 else {
                     mem.removeOffHeap(valPtr);
@@ -302,41 +296,42 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
     /** {@inheritDoc} */
     @Override public int memorySize() throws IgniteCheckedException {
-        byte[] kb;
-        GridCacheValueBytes vb;
-
-        V v;
-
-        int extrasSize;
-
-        synchronized (this) {
-            kb = keyBytes;
-            vb = valueBytesUnlocked();
-
-            v = val;
-
-            extrasSize = extrasSize();
-        }
-
-        if (kb == null || (vb.isNull() && v != null)) {
-            if (kb == null)
-                kb = CU.marshal(cctx.shared(), key);
-
-            if (vb.isNull())
-                vb = (v != null && v instanceof byte[]) ? 
GridCacheValueBytes.plain(v) :
-                    GridCacheValueBytes.marshaled(CU.marshal(cctx.shared(), 
v));
-
-            synchronized (this) {
-                if (keyBytes == null)
-                    keyBytes = kb;
-
-                // If value didn't change.
-                if (!isOffHeapValuesOnly() && valBytes == null && val == v && 
cctx.config().isStoreValueBytes())
-                    valBytes = vb.isPlain() ? null : vb.get();
-            }
-        }
-
-        return SIZE_OVERHEAD + extrasSize + kb.length + (vb.isNull() ? 0 : 
vb.get().length);
+// TODO IGNITE-51
+//        byte[] kb;
+//        GridCacheValueBytes vb;
+//
+//        CacheObject v;
+//
+//        int extrasSize;
+//
+//        synchronized (this) {
+//            kb = keyBytes;
+//            vb = valueBytesUnlocked();
+//
+//            v = val;
+//
+//            extrasSize = extrasSize();
+//        }
+//
+//        if (kb == null || (vb.isNull() && v != null)) {
+//            if (kb == null)
+//                kb = CU.marshal(cctx.shared(), key);
+//
+//            if (vb.isNull())
+//                vb = (v != null && v instanceof byte[]) ? 
GridCacheValueBytes.plain(v) :
+//                    GridCacheValueBytes.marshaled(CU.marshal(cctx.shared(), 
v));
+//
+//            synchronized (this) {
+//                if (keyBytes == null)
+//                    keyBytes = kb;
+//
+//                // If value didn't change.
+//                if (!isOffHeapValuesOnly() && valBytes == null && val == v 
&& cctx.config().isStoreValueBytes())
+//                    valBytes = vb.isPlain() ? null : vb.get();
+//            }
+//        }
+//
+//        return SIZE_OVERHEAD + extrasSize + kb.length + (vb.isNull() ? 0 : 
vb.get().length);
     }
 
     /** {@inheritDoc} */
@@ -370,8 +365,8 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheContext<K, V> context() {
-        return cctx;
+    @Override public <K, V> GridCacheContext<K, V> context() {
+        return (GridCacheContext<K, V>)cctx;
     }
 
     /** {@inheritDoc} */
@@ -413,15 +408,15 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public GridCacheEntryInfo<K, V> info() {
-        GridCacheEntryInfo<K, V> info = null;
+    @Nullable @Override public GridCacheEntryInfo info() {
+        GridCacheEntryInfo info = null;
 
         long time = U.currentTimeMillis();
 
         try {
             synchronized (this) {
                 if (!obsolete()) {
-                    info = new GridCacheEntryInfo<>();
+                    info = new GridCacheEntryInfo();
 
                     info.key(key);
                     info.cacheId(cctx.cacheId());
@@ -430,7 +425,6 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
                     boolean expired = expireTime != 0 && expireTime <= time;
 
-                    info.keyBytes(keyBytes);
                     info.ttl(ttlExtras());
                     info.expireTime(expireTime);
                     info.version(ver);
@@ -438,22 +432,24 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                     info.setDeleted(deletedUnlocked());
 
                     if (!expired) {
-                        
info.value(cctx.kernalContext().config().isPeerClassLoadingEnabled() ?
-                            rawGetOrUnmarshalUnlocked(false) : val);
-
-                        GridCacheValueBytes valBytes = valueBytesUnlocked();
-
-                        if (!valBytes.isNull()) {
-                            if (valBytes.isPlain())
-                                info.value((V)valBytes.get());
-                            else
-                                info.valueBytes(valBytes.get());
-                        }
-                    }
+                        info.value(val);
+// TODO IGNITE-51.
+//                        
info.value(cctx.kernalContext().config().isPeerClassLoadingEnabled() ?
+//                            rawGetOrUnmarshalUnlocked(false) : val);
+//
+//                        GridCacheValueBytes valBytes = valueBytesUnlocked();
+//
+//                        if (!valBytes.isNull()) {
+//                            if (valBytes.isPlain())
+//                                info.value((V)valBytes.get());
+//                            else
+//                                info.valueBytes(valBytes.get());
+//                        }
+                   }
                 }
             }
         }
-        catch (IgniteCheckedException e) {
+        catch (Exception e) {
             throw new IgniteException("Failed to unmarshal object while 
creating entry info: " + this, e);
         }
 
@@ -461,7 +457,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public V unswap() throws IgniteCheckedException {
+    @Override public CacheObject unswap() throws IgniteCheckedException {
         return unswap(false, true);
     }
 
@@ -473,7 +469,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @return Value.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable @Override public V unswap(boolean ignoreFlags, boolean needVal) 
throws IgniteCheckedException {
+    @Nullable @Override public CacheObject unswap(boolean ignoreFlags, boolean 
needVal) throws IgniteCheckedException {
         boolean swapEnabled = cctx.swap().swapEnabled() && (ignoreFlags || 
!cctx.hasFlag(SKIP_SWAP));
 
         if (!swapEnabled && !cctx.isOffHeapEnabled())
@@ -481,7 +477,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
         synchronized (this) {
             if (isStartVersion() && ((flags & IS_UNSWAPPED_MASK) == 0)) {
-                GridCacheSwapEntry<V> e;
+                GridCacheSwapEntry e;
 
                 if (cctx.offheapTiered()) {
                     e = cctx.swap().readOffheapPointer(this);
@@ -491,7 +487,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                             valPtr = e.offheapPointer();
 
                             if (needVal) {
-                                V val = unmarshalOffheap(false);
+                                CacheObject val = unmarshalOffheap(false);
 
                                 e.value(val);
                             }
@@ -517,10 +513,10 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                     long delta = e.expireTime() == 0 ? 0 : e.expireTime() - 
U.currentTimeMillis();
 
                     if (delta >= 0) {
-                        V val = e.value();
+                        CacheObject val = e.value();
 
                         if (cctx.portableEnabled())
-                            val = 
(V)cctx.kernalContext().portable().detachPortable(val);
+                            val = 
(CacheObject)cctx.kernalContext().portable().detachPortable(val);
 
                         // Set unswapped value.
                         update(val, e.valueBytes(), e.expireTime(), e.ttl(), 
e.version());
@@ -616,13 +612,13 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"RedundantTypeArguments"})
-    @Nullable protected V readThrough(@Nullable IgniteInternalTx<K, V> tx, K 
key, boolean reload, UUID subjId,
+    @Nullable protected Object readThrough(@Nullable IgniteInternalTx tx, 
KeyCacheObject key, boolean reload, UUID subjId,
         String taskName) throws IgniteCheckedException {
         return cctx.store().loadFromStore(tx, key);
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public final V innerGet(@Nullable IgniteInternalTx<K, 
V> tx,
+    @Nullable @Override public final CacheObject innerGet(@Nullable 
IgniteInternalTx tx,
         boolean readSwap,
         boolean readThrough,
         boolean failFast,
@@ -652,7 +648,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
     /** {@inheritDoc} */
     @SuppressWarnings({"unchecked", "RedundantTypeArguments", "TooBroadScope"})
-    private V innerGet0(IgniteInternalTx<K, V> tx,
+    private CacheObject innerGet0(IgniteInternalTx tx,
         boolean readSwap,
         boolean readThrough,
         boolean evt,
@@ -668,16 +664,16 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
         if (readThrough && !cctx.readThrough())
             readThrough = false;
 
-        GridCacheMvccCandidate<K> owner;
+        GridCacheMvccCandidate owner;
 
-        V old;
-        V ret = null;
+        CacheObject old;
+        CacheObject ret = null;
 
         GridCacheVersion startVer;
 
         boolean expired = false;
 
-        V expiredVal = null;
+        CacheObject expiredVal = null;
 
         boolean hasOldBytes;
 
@@ -687,7 +683,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
             // Cache version for optimistic check.
             startVer = ver;
 
-            GridCacheMvcc<K> mvcc = mvccExtras();
+            GridCacheMvcc mvcc = mvccExtras();
 
             owner = mvcc == null ? null : mvcc.anyOwner();
 
@@ -705,7 +701,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                     expired = true;
             }
 
-            V val = this.val;
+            CacheObject val = this.val;
 
             hasOldBytes = valBytes != null || valPtr != 0;
 
@@ -848,11 +844,11 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                 if (ret != null) {
                     // Detach value before index update.
                     if (cctx.portableEnabled())
-                        ret = 
(V)cctx.kernalContext().portable().detachPortable(ret);
+                        ret = 
(CacheObject)cctx.kernalContext().portable().detachPortable(ret);
 
                     GridCacheVersion nextVer = nextVersion();
 
-                    V prevVal = rawGetOrUnmarshalUnlocked(false);
+                    CacheObject prevVal = rawGetOrUnmarshalUnlocked(false);
 
                     long expTime = CU.toExpireTime(ttl);
 
@@ -1555,7 +1551,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheUpdateAtomicResult<K, V> innerUpdate(
+    @Override public GridCacheUpdateAtomicResult innerUpdate(
         GridCacheVersion newVer,
         UUID evtNodeId,
         UUID affNodeId,
@@ -1570,7 +1566,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
         boolean metrics,
         boolean primary,
         boolean verCheck,
-        @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter,
+        @Nullable IgnitePredicate<Cache.Entry<Object, Object>>[] filter,
         GridDrType drType,
         long conflictTtl,
         long conflictExpireTime,
@@ -1643,8 +1639,8 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                         newExpireTime = CU.toExpireTime(newTtl);
                     }
 
-                    GridCacheVersionedEntryEx<K, V> oldEntry = 
versionedEntry();
-                    GridCacheVersionedEntryEx<K, V> newEntry =
+                    GridCacheVersionedEntryEx oldEntry = versionedEntry();
+                    GridCacheVersionedEntryEx newEntry =
                         new GridCachePlainVersionedEntry<>(k, (V)writeObj, 
newTtl, newExpireTime, conflictVer);
 
                     drRes = cctx.conflictResolve(oldEntry, newEntry, verCheck);
@@ -2513,7 +2509,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @param ttl Time to live.
      * @param ver Update version.
      */
-    protected final void update(@Nullable V val, @Nullable byte[] valBytes, 
long expireTime, long ttl,
+    protected final void update(@Nullable CacheObject val, @Nullable byte[] 
valBytes, long expireTime, long ttl,
         GridCacheVersion ver) {
         assert ver != null;
         assert Thread.holdsLock(this);
@@ -2586,12 +2582,12 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public K key() {
+    @Override public KeyCacheObject key() {
         return key;
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteTxKey<K> txKey() {
+    @Override public IgniteTxKey txKey() {
         return cctx.txKey(key);
     }
 
@@ -2617,7 +2613,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @param segId Segment ID.
      * @return Next entry.
      */
-    GridCacheMapEntry<K, V> next(int segId) {
+    GridCacheMapEntry next(int segId) {
         return segId % 2 == 0 ? next0 : next1;
     }
 
@@ -2627,7 +2623,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @param segId Segment ID.
      * @param next Next entry.
      */
-    void next(int segId, @Nullable GridCacheMapEntry<K, V> next) {
+    void next(int segId, @Nullable GridCacheMapEntry next) {
         if (segId % 2 == 0)
             next0 = next;
         else
@@ -2635,10 +2631,11 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V peek(GridCachePeekMode mode, 
IgnitePredicate<Cache.Entry<K, V>>[] filter)
+    @Nullable @Override public <K, V> CacheObject peek(GridCachePeekMode mode,
+        IgnitePredicate<Cache.Entry<K, V>>[] filter)
         throws GridCacheEntryRemovedException {
         try {
-            GridTuple<V> peek = peek0(false, mode, filter, 
cctx.tm().localTxx());
+            GridTuple<CacheObject> peek = peek0(false, mode, filter, 
cctx.tm().localTxx());
 
             return peek != null ? peek.get() : null;
         }
@@ -2653,7 +2650,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V peek(boolean heap,
+    @Nullable @Override public CacheObject peek(boolean heap,
         boolean offheap,
         boolean swap,
         long topVer,
@@ -2664,7 +2661,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
 
         try {
             if (heap) {
-                GridTuple<V> val = peekGlobal(false, topVer, null, expiryPlc);
+                GridTuple<CacheObject> val = peekGlobal(false, topVer, null, 
expiryPlc);
 
                 if (val != null)
                     return val.get();
@@ -2885,7 +2882,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @throws IgniteCheckedException If unexpected cache failure occurred.
      */
     @SuppressWarnings({"RedundantTypeArguments"})
-    @Nullable private GridTuple<V> peekGlobal(boolean failFast,
+    @Nullable private <K, V> GridTuple<CacheObject> peekGlobal(boolean 
failFast,
         long topVer,
         IgnitePredicate<Cache.Entry<K, V>>[] filter,
         @Nullable IgniteCacheExpiryPolicy expiryPlc
@@ -2928,7 +2925,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                 }
 
                 if (!cctx.isAll(wrap(), filter))
-                    return F.t(CU.<V>failed(failFast));
+                    return F.t(CU.<CacheObject>failed(failFast));
 
                 if (F.isEmptyOrNulls(filter) || ver.equals(version()))
                     return F.t(val);
@@ -3019,12 +3016,12 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     /**
      * @return Value.
      */
-    @Override public synchronized V rawGet() {
+    @Override public synchronized CacheObject rawGet() {
         return val;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public synchronized V rawGetOrUnmarshal(boolean tmp) 
throws IgniteCheckedException {
+    @Nullable @Override public synchronized CacheObject 
rawGetOrUnmarshal(boolean tmp) throws IgniteCheckedException {
         return rawGetOrUnmarshalUnlocked(tmp);
     }
 
@@ -3033,10 +3030,10 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
      * @return Value (unmarshalled if needed).
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable public V rawGetOrUnmarshalUnlocked(boolean tmp) throws 
IgniteCheckedException {
+    @Nullable public CacheObject rawGetOrUnmarshalUnlocked(boolean tmp) throws 
IgniteCheckedException {
         assert Thread.holdsLock(this);
 
-        V val = this.val;
+        CacheObject val = this.val;
 
         if (val != null)
             return val;
@@ -3068,8 +3065,8 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized V rawPut(V val, long ttl) {
-        V old = this.val;
+    @Override public synchronized CacheObject rawPut(CacheObject val, long 
ttl) {
+        CacheObject old = this.val;
 
         update(val, null, CU.toExpireTime(ttl), ttl, nextVersion());
 
@@ -3638,14 +3635,14 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
      * @param prevVal Previous value (if needed for index update).
      * @throws IgniteCheckedException If failed.
      */
-    protected void clearIndex(@Nullable V prevVal) throws 
IgniteCheckedException {
+    protected void clearIndex(@Nullable CacheObject prevVal) throws 
IgniteCheckedException {
         assert Thread.holdsLock(this);
 
         try {
-            GridCacheQueryManager<K, V> qryMgr = cctx.queries();
+            GridCacheQueryManager<?, ?> qryMgr = cctx.queries();
 
             if (qryMgr != null)
-                qryMgr.remove(key(), keyBytes());
+                qryMgr.remove(key());
         }
         catch (IgniteCheckedException e) {
             throw new GridCacheIndexUpdateException(e);
@@ -3659,7 +3656,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      * @return Previous value or {@code null}.
      * @throws IgniteCheckedException If failed to retrieve previous value.
      */
-    protected V saveValueForIndexUnlocked() throws IgniteCheckedException {
+    protected CacheObject saveValueForIndexUnlocked() throws 
IgniteCheckedException {
         assert Thread.holdsLock(this);
 
         if (!cctx.cache().isMongoDataCache() && 
!cctx.cache().isMongoMetaCache())
@@ -3670,21 +3667,21 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
-    @Override public Cache.Entry<K, V> wrap() {
+    @Override public <K, V> Cache.Entry<K, V> wrap() {
         try {
-            IgniteInternalTx<K, V> tx = cctx.tm().userTx();
+            IgniteInternalTx tx = cctx.tm().userTx();
 
-            V val;
+            CacheObject val;
 
             if (tx != null) {
-                GridTuple<V> peek = tx.peek(cctx, false, key, null);
+                GridTuple<CacheObject> peek = tx.peek(cctx, false, key, null);
 
                 val = peek == null ? rawGetOrUnmarshal(false) : peek.get();
             }
             else
                 val = rawGetOrUnmarshal(false);
 
-            return new CacheEntryImpl<>(key, val);
+            return new CacheEntryImpl<>(key.<K>value(cctx), val != null ? 
val.<V>value(cctx) : null);
         }
         catch (GridCacheFilterFailedException ignored) {
             throw new IgniteException("Should never happen.");
@@ -3695,34 +3692,36 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public Cache.Entry<K, V> wrapLazyValue() {
+    @Override public <K, V> Cache.Entry<K, V> wrapLazyValue() {
         return new LazyValueEntry(key);
     }
 
         /** {@inheritDoc} */
-    @Override public Cache.Entry<K, V> wrapFilterLocked() throws 
IgniteCheckedException {
-        return new CacheEntryImpl<>(key, rawGetOrUnmarshal(true));
+    @Override public <K, V> Cache.Entry<K, V> wrapFilterLocked() throws 
IgniteCheckedException {
+        CacheObject val = rawGetOrUnmarshal(true);
+
+        return new CacheEntryImpl<>(key.<K>value(cctx), val != null ? 
val.<V>value(cctx) : null) ;
     }
 
     /** {@inheritDoc} */
-    @Override public EvictableEntry<K, V> wrapEviction() {
+    @Override public <K, V> EvictableEntry<K, V> wrapEviction() {
         return new EvictableEntryImpl<>(this);
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized CacheVersionedEntryImpl<K, V> 
wrapVersioned() {
-        return new CacheVersionedEntryImpl<>(key, null, ver);
+    @Override public synchronized <K, V> CacheVersionedEntryImpl<K, V> 
wrapVersioned() {
+        return new CacheVersionedEntryImpl<>(key.<K>value(cctx), null, ver);
     }
 
     /** {@inheritDoc} */
-    @Override public boolean evictInternal(boolean swap, GridCacheVersion 
obsoleteVer,
+    @Override public <K, V> boolean evictInternal(boolean swap, 
GridCacheVersion obsoleteVer,
         @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter) throws 
IgniteCheckedException {
         boolean marked = false;
 
         try {
             if (F.isEmptyOrNulls(filter)) {
                 synchronized (this) {
-                    V prev = saveValueForIndexUnlocked();
+                    CacheObject prev = saveValueForIndexUnlocked();
 
                     if (!hasReaders() && markObsolete0(obsoleteVer, false)) {
                         if (swap) {
@@ -3757,7 +3756,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                         v = ver;
                     }
 
-                    if (!cctx.isAll(/*version needed for sync 
evicts*/wrapVersioned(), filter))
+                    if (!cctx.isAll(/*version needed for sync evicts*/this.<K, 
V>wrapVersioned(), filter))
                         return false;
 
                     synchronized (this) {
@@ -3765,7 +3764,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
                             // Version has changed since entry passed the 
filter. Do it again.
                             continue;
 
-                        V prevVal = saveValueForIndexUnlocked();
+                        CacheObject prevVal = saveValueForIndexUnlocked();
 
                         if (!hasReaders() && markObsolete0(obsoleteVer, 
false)) {
                             if (swap) {
@@ -3810,12 +3809,12 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheBatchSwapEntry<K, V> 
evictInBatchInternal(GridCacheVersion obsoleteVer)
+    @Override public GridCacheBatchSwapEntry 
evictInBatchInternal(GridCacheVersion obsoleteVer)
         throws IgniteCheckedException {
         assert Thread.holdsLock(this);
         assert cctx.isSwapOrOffheapEnabled();
 
-        GridCacheBatchSwapEntry<K, V> ret = null;
+        GridCacheBatchSwapEntry ret = null;
 
         try {
             if (!hasReaders() && markObsolete0(obsoleteVer, false)) {
@@ -3883,10 +3882,10 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
      * @param filter Entry filter.
      * @return {@code True} if entry is visitable.
      */
-    public boolean visitable(IgnitePredicate<Cache.Entry<K, V>>[] filter) {
+    public <K, V> boolean visitable(IgnitePredicate<Cache.Entry<K, V>>[] 
filter) {
         try {
             if (obsoleteOrDeleted() || (filter != CU.<K, V>empty() &&
-                !cctx.isAll(wrapLazyValue(), filter)))
+                !cctx.isAll(this.<K, V> wrapLazyValue(), filter)))
                 return false;
         }
         catch (IgniteCheckedException e) {
@@ -3905,7 +3904,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
             return false;
         }
 
-        IgniteInternalTx<K, V> tx = cctx.tm().localTxx();
+        IgniteInternalTx tx = cctx.tm().localTxx();
 
         return tx == null || !tx.removed(txKey());
     }
@@ -4158,21 +4157,21 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
      */
     private void attributeDataExtras(@Nullable GridLeanMap<String, Object> 
attrData) {
         extras = (extras != null) ? extras.attributesData(attrData) : attrData 
!= null ?
-            new GridCacheAttributesEntryExtras<K>(attrData) : null;
+            new GridCacheAttributesEntryExtras(attrData) : null;
     }
 
     /**
      * @return MVCC.
      */
-    @Nullable protected GridCacheMvcc<K> mvccExtras() {
+    @Nullable protected GridCacheMvcc mvccExtras() {
         return extras != null ? extras.mvcc() : null;
     }
 
     /**
      * @param mvcc MVCC.
      */
-    protected void mvccExtras(@Nullable GridCacheMvcc<K> mvcc) {
-        extras = (extras != null) ? extras.mvcc(mvcc) : mvcc != null ? new 
GridCacheMvccEntryExtras<>(mvcc) : null;
+    protected void mvccExtras(@Nullable GridCacheMvcc mvcc) {
+        extras = (extras != null) ? extras.mvcc(mvcc) : mvcc != null ? new 
GridCacheMvccEntryExtras(mvcc) : null;
     }
 
     /**
@@ -4187,7 +4186,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      */
     protected void obsoleteVersionExtras(@Nullable GridCacheVersion 
obsoleteVer) {
         extras = (extras != null) ? extras.obsoleteVersion(obsoleteVer) : 
obsoleteVer != null ?
-            new GridCacheObsoleteEntryExtras<K>(obsoleteVer) : null;
+            new GridCacheObsoleteEntryExtras(obsoleteVer) : null;
     }
 
     /**
@@ -4225,7 +4224,7 @@ public abstract class GridCacheMapEntry<K, V> implements 
GridCacheEntryEx<K, V>
      */
     protected void ttlAndExpireTimeExtras(long ttl, long expireTime) {
         extras = (extras != null) ? extras.ttlAndExpireTime(ttl, expireTime) : 
ttl != 0 ?
-            new GridCacheTtlEntryExtras<K>(ttl, expireTime) : null;
+            new GridCacheTtlEntryExtras(ttl, expireTime) : null;
     }
 
     /**
@@ -4264,11 +4263,11 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
      * @return Unmarshalled value.
      * @throws IgniteCheckedException If unmarshalling failed.
      */
-    private V unmarshalOffheap(boolean tmp) throws IgniteCheckedException {
+    private CacheObject unmarshalOffheap(boolean tmp) throws 
IgniteCheckedException {
         assert cctx.offheapTiered() && valPtr != 0;
 
         if (cctx.portableEnabled())
-            return (V)cctx.portable().unmarshal(valPtr, !tmp);
+            return (CacheObject)cctx.portable().unmarshal(valPtr, !tmp);
 
         long ptr = valPtr;
 
@@ -4308,46 +4307,46 @@ public abstract class GridCacheMapEntry<K, V> 
implements GridCacheEntryEx<K, V>
     /**
      *
      */
-    private class LazyValueEntry implements Cache.Entry<K, V> {
+    private class LazyValueEntry<K, V> implements Cache.Entry<K, V> {
         /** */
-        private final K key;
+        private final KeyCacheObject key;
 
         /**
          * @param key Key.
          */
-        private LazyValueEntry(K key) {
+        private LazyValueEntry(KeyCacheObject key) {
             this.key = key;
         }
 
         /** {@inheritDoc} */
         @Override public K getKey() {
-            return key;
+            return key.value(cctx);
         }
 
         /** {@inheritDoc} */
         @SuppressWarnings("unchecked")
         @Override public V getValue() {
             try {
-                IgniteInternalTx<K, V> tx = cctx.tm().userTx();
+                IgniteInternalTx tx = cctx.tm().userTx();
 
                 if (tx != null) {
-                    GridTuple<V> peek = tx.peek(cctx, false, key, null);
+                    GridTuple<CacheObject> peek = tx.peek(cctx, false, key, 
null);
 
                     if (peek != null)
-                        return peek.get();
+                        return peek.get().value(cctx);
                 }
 
                 if (detached())
-                    return rawGet();
+                    return rawGet().value(cctx);
 
                 for (;;) {
-                    GridCacheEntryEx<K, V> e = cctx.cache().peekEx(key);
+                    GridCacheEntryEx e = cctx.cache().peekEx(key);
 
                     if (e == null)
                         return null;
 
                     try {
-                        return e.peek(GridCachePeekMode.GLOBAL, CU.<K, 
V>empty());
+                        return e.peek(GridCachePeekMode.GLOBAL, CU.<K, 
V>empty()).value(cctx);
                     }
                     catch (GridCacheEntryRemovedException ignored) {
                         // No-op.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntryFactory.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntryFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntryFactory.java
index ad7cf9e..71e5295 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntryFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntryFactory.java
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.*;
 /**
  * Factory for cache entries.
  */
-public interface GridCacheMapEntryFactory<K, V> {
+public interface GridCacheMapEntryFactory {
     /**
      * @param ctx Cache registry.
      * @param topVer Topology version.
@@ -34,6 +34,6 @@ public interface GridCacheMapEntryFactory<K, V> {
      * @param hdrId Header id.
      * @return New cache entry.
      */
-    public GridCacheMapEntry<K, V> create(GridCacheContext<K, V> ctx, long 
topVer, K key, int hash, V val,
-        @Nullable GridCacheMapEntry<K, V> next, long ttl, int hdrId);
+    public GridCacheMapEntry create(GridCacheContext ctx, long topVer, 
KeyCacheObject key, int hash, CacheObject val,
+        @Nullable GridCacheMapEntry next, long ttl, int hdrId);
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index 839031b..899d073 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.*;
 /**
  * Parent of all cache messages.
  */
-public abstract class GridCacheMessage<K, V> extends MessageAdapter {
+public abstract class GridCacheMessage extends MessageAdapter {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -172,8 +172,8 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void prepareFilter(@Nullable 
IgnitePredicate<Cache.Entry<K, V>>[] filters,
-        GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+    protected final void prepareFilter(@Nullable 
IgnitePredicate<Cache.Entry<Object, Object>>[] filters,
+        GridCacheSharedContext ctx) throws IgniteCheckedException {
         if (filters != null)
             for (IgnitePredicate filter : filters)
                 prepareObject(filter, ctx);
@@ -184,7 +184,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void prepareObject(@Nullable Object o, 
GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+    protected final void prepareObject(@Nullable Object o, 
GridCacheSharedContext ctx) throws IgniteCheckedException {
         if (!skipPrepare && o != null) {
             GridDeploymentInfo d = ctx.deploy().globalDeploymentInfo();
 
@@ -212,7 +212,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Cache context.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void prepareObjects(@Nullable Iterable<?> col, 
GridCacheSharedContext<K, V> ctx)
+    protected final void prepareObjects(@Nullable Iterable<?> col, 
GridCacheSharedContext ctx)
         throws IgniteCheckedException {
         if (col != null)
             for (Object o : col)
@@ -250,7 +250,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Cache context.
      * @throws IgniteCheckedException If failed.
      */
-    public void prepareMarshal(GridCacheSharedContext<K, V> ctx) throws 
IgniteCheckedException {
+    public void prepareMarshal(GridCacheSharedContext ctx) throws 
IgniteCheckedException {
         // No-op.
     }
 
@@ -262,7 +262,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ldr Class loader.
      * @throws IgniteCheckedException If failed.
      */
-    public void finishUnmarshal(GridCacheSharedContext<K, V> ctx, ClassLoader 
ldr) throws IgniteCheckedException {
+    public void finishUnmarshal(GridCacheSharedContext ctx, ClassLoader ldr) 
throws IgniteCheckedException {
         // No-op.
     }
 
@@ -271,7 +271,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void marshalInfo(GridCacheEntryInfo<K, V> info, 
GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+    protected final void marshalInfo(GridCacheEntryInfo info, 
GridCacheSharedContext ctx) throws IgniteCheckedException {
         assert ctx != null;
 
         if (info != null) {
@@ -290,7 +290,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ldr Loader.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void unmarshalInfo(GridCacheEntryInfo<K, V> info, 
GridCacheContext<K, V> ctx,
+    protected final void unmarshalInfo(GridCacheEntryInfo info, 
GridCacheContext ctx,
         ClassLoader ldr) throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
@@ -305,13 +305,13 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     protected final void marshalInfos(
-        Iterable<? extends GridCacheEntryInfo<K, V>> infos,
-        GridCacheSharedContext<K, V> ctx
+        Iterable<? extends GridCacheEntryInfo> infos,
+        GridCacheSharedContext ctx
     ) throws IgniteCheckedException {
         assert ctx != null;
 
         if (infos != null)
-            for (GridCacheEntryInfo<K, V> e : infos)
+            for (GridCacheEntryInfo e : infos)
                 marshalInfo(e, ctx);
     }
 
@@ -321,13 +321,13 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ldr Loader.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void unmarshalInfos(Iterable<? extends 
GridCacheEntryInfo<K, V>> infos,
-        GridCacheContext<K, V> ctx, ClassLoader ldr) throws 
IgniteCheckedException {
+    protected final void unmarshalInfos(Iterable<? extends GridCacheEntryInfo> 
infos,
+        GridCacheContext ctx, ClassLoader ldr) throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
 
         if (infos != null)
-            for (GridCacheEntryInfo<K, V> e : infos)
+            for (GridCacheEntryInfo e : infos)
                 unmarshalInfo(e, ctx, ldr);
     }
 
@@ -336,14 +336,14 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ctx Context.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void marshalTx(Iterable<IgniteTxEntry<K, V>> txEntries, 
GridCacheSharedContext<K, V> ctx)
+    protected final void marshalTx(Iterable<IgniteTxEntry> txEntries, 
GridCacheSharedContext ctx)
         throws IgniteCheckedException {
         assert ctx != null;
 
         if (txEntries != null) {
             boolean transferExpiry = transferExpiryPolicy();
 
-            for (IgniteTxEntry<K, V> e : txEntries) {
+            for (IgniteTxEntry e : txEntries) {
                 e.marshal(ctx, transferExpiry);
 
                 if (ctx.deploymentEnabled()) {
@@ -368,15 +368,15 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @param ldr Loader.
      * @throws IgniteCheckedException If failed.
      */
-    protected final void unmarshalTx(Iterable<IgniteTxEntry<K, V>> txEntries,
+    protected final void unmarshalTx(Iterable<IgniteTxEntry> txEntries,
         boolean near,
-        GridCacheSharedContext<K, V> ctx,
+        GridCacheSharedContext ctx,
         ClassLoader ldr) throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
 
         if (txEntries != null) {
-            for (IgniteTxEntry<K, V> e : txEntries)
+            for (IgniteTxEntry e : txEntries)
                 e.unmarshal(ctx, near, ldr);
         }
     }
@@ -388,7 +388,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected final byte[][] marshalInvokeArguments(@Nullable 
Object[] args,
-        GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+        GridCacheSharedContext ctx) throws IgniteCheckedException {
         assert ctx != null;
 
         if (args == null || args.length == 0)
@@ -417,7 +417,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected final Object[] unmarshalInvokeArguments(@Nullable 
byte[][] byteCol,
-        GridCacheSharedContext<K, V> ctx,
+        GridCacheSharedContext ctx,
         ClassLoader ldr) throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
@@ -441,8 +441,11 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @return Marshalled collection.
      * @throws IgniteCheckedException If failed.
      */
-    @Nullable protected final <T> byte[][] marshalFilter(@Nullable 
IgnitePredicate<Cache.Entry<K, V>>[] filter,
-        GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+    @Nullable protected final <T> byte[][] marshalFilter(
+        @Nullable IgnitePredicate<Cache.Entry<Object, Object>>[] filter,
+        GridCacheSharedContext ctx)
+        throws IgniteCheckedException
+    {
         assert ctx != null;
 
         if (filter == null)
@@ -451,7 +454,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
         byte[][] filterBytes = new byte[filter.length][];
 
         for (int i = 0; i < filter.length; i++) {
-            IgnitePredicate<Cache.Entry<K, V>> p = filter[i];
+            IgnitePredicate<Cache.Entry<Object, Object>> p = filter[i];
 
             if (ctx.deploymentEnabled())
                 prepareObject(p, ctx);
@@ -470,21 +473,23 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable protected final <T> IgnitePredicate<Cache.Entry<K, V>>[] 
unmarshalFilter(
-        @Nullable byte[][] byteCol, GridCacheSharedContext<K, V> ctx, 
ClassLoader ldr) throws IgniteCheckedException {
+    @Nullable protected final <T> IgnitePredicate<Cache.Entry<Object, 
Object>>[] unmarshalFilter(
+        @Nullable byte[][] byteCol, GridCacheSharedContext<Object, Object> 
ctx, ClassLoader ldr)
+        throws IgniteCheckedException
+    {
         assert ldr != null;
         assert ctx != null;
 
         if (byteCol == null)
             return null;
 
-        IgnitePredicate<Cache.Entry<K, V>>[] filter = new 
IgnitePredicate[byteCol.length];
+        IgnitePredicate<Cache.Entry<Object, Object>>[] filter = new 
IgnitePredicate[byteCol.length];
 
         Marshaller marsh = ctx.marshaller();
 
         for (int i = 0; i < byteCol.length; i++)
             filter[i] = byteCol[i] == null ? null :
-                marsh.<IgnitePredicate<Cache.Entry<K, 
V>>>unmarshal(byteCol[i], ldr);
+                marsh.<IgnitePredicate<Cache.Entry<Object, 
Object>>>unmarshal(byteCol[i], ldr);
 
         return filter;
     }
@@ -496,7 +501,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected List<GridCacheValueBytes> 
marshalValuesCollection(@Nullable Collection<?> col,
-        GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+        GridCacheSharedContext ctx) throws IgniteCheckedException {
         assert ctx != null;
 
         if (col == null)
@@ -523,7 +528,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected <T> List<T> unmarshalValueBytesCollection(@Nullable 
Collection<GridCacheValueBytes> byteCol,
-        GridCacheSharedContext<K, V> ctx, ClassLoader ldr)
+        GridCacheSharedContext ctx, ClassLoader ldr)
         throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
@@ -551,7 +556,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected List<byte[]> marshalCollection(@Nullable Collection<?> 
col,
-        GridCacheSharedContext<K, V> ctx) throws IgniteCheckedException {
+        GridCacheSharedContext ctx) throws IgniteCheckedException {
         assert ctx != null;
 
         if (col == null)
@@ -577,7 +582,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected <T> List<T> unmarshalCollection(@Nullable 
Collection<byte[]> byteCol,
-        GridCacheSharedContext<K, V> ctx, ClassLoader ldr) throws 
IgniteCheckedException {
+        GridCacheSharedContext ctx, ClassLoader ldr) throws 
IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
 
@@ -602,7 +607,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      */
     @SuppressWarnings("TypeMayBeWeakened") // Don't weaken type to clearly see 
that it's linked hash map.
     @Nullable protected final LinkedHashMap<byte[], Boolean> 
marshalBooleanLinkedMap(
-        @Nullable LinkedHashMap<?, Boolean> map, GridCacheSharedContext<K, V> 
ctx) throws IgniteCheckedException {
+        @Nullable LinkedHashMap<?, Boolean> map, GridCacheSharedContext ctx) 
throws IgniteCheckedException {
         assert ctx != null;
 
         if (map == null)
@@ -628,7 +633,7 @@ public abstract class GridCacheMessage<K, V> extends 
MessageAdapter {
      * @throws IgniteCheckedException If failed.
      */
     @Nullable protected final <K1> LinkedHashMap<K1, Boolean> 
unmarshalBooleanLinkedMap(
-        @Nullable Map<byte[], Boolean> byteMap, GridCacheSharedContext<K, V> 
ctx, ClassLoader ldr) throws IgniteCheckedException {
+        @Nullable Map<byte[], Boolean> byteMap, GridCacheSharedContext ctx, 
ClassLoader ldr) throws IgniteCheckedException {
         assert ldr != null;
         assert ctx != null;
 

Reply via email to