/**
   * @param keyBytes Key to remove.
   * @return {@code true} if value was actually removed, {@code false} otherwise.
   * @throws GridException If failed.
   */
  @SuppressWarnings({"unchecked"})
  @Nullable
  GridCacheSwapEntry<V> read(byte[] keyBytes) throws GridException {
    if (!enabled) return null;

    GridSwapByteArray valBytes = swapMgr.read(spaceName, new GridSwapByteArray(keyBytes));

    if (valBytes == null) return null;

    // To unmarshal swap entry itself local class loader will be enough.
    return recreateEntry((GridCacheSwapEntry<V>) unmarshal(valBytes, cctx.deploy().localLoader()));
  }
  /**
   * Writes a versioned value to swap.
   *
   * @param key Key.
   * @param val Value.
   * @param ver Version.
   * @param metrics Metrics.
   * @param ttl Entry time to live.
   * @param expireTime Swap entry expiration time.
   * @param clsLdrId Class loader id for entry value.
   * @throws GridException If failed.
   */
  void write(
      byte[] key,
      byte[] val,
      GridCacheVersion ver,
      long ttl,
      long expireTime,
      GridCacheMetricsAdapter metrics,
      UUID clsLdrId)
      throws GridException {
    if (!enabled) return;

    GridCacheSwapEntry<V> entry =
        new GridCacheSwapEntry<V>(val, ver, ttl, expireTime, metrics, clsLdrId);

    swapMgr.write(spaceName, new GridSwapByteArray(key), new GridSwapByteArray(marshal(entry)));
  }
  /**
   * @param keyBytes Key to remove.
   * @return {@code true} if value was actually removed, {@code false} otherwise.
   * @throws GridException If failed.
   */
  @SuppressWarnings({"unchecked"})
  @Nullable
  GridCacheSwapEntry<V> readAndRemove(byte[] keyBytes) throws GridException {
    if (!enabled) return null;

    final GridTuple<GridSwapByteArray> t = F.t1();

    swapMgr.remove(
        spaceName,
        new GridSwapByteArray(keyBytes),
        new CI1<GridSwapByteArray>() {
          @Override
          public void apply(GridSwapByteArray removed) {
            t.set(removed);
          }
        });

    if (t.get() == null) return null;

    // To unmarshal swap entry itself local class loader will be enough.
    return recreateEntry((GridCacheSwapEntry<V>) unmarshal(t.get(), cctx.deploy().localLoader()));
  }
 /**
  * @return Swap size.
  * @throws GridException If failed.
  */
 long swapSize() throws GridException {
   return enabled ? swapMgr.swapSize(spaceName) : -1;
 }
 /**
  * @param key Key to remove.
  * @return {@code true} if value was actually removed, {@code false} otherwise.
  * @throws GridException If failed.
  */
 boolean remove(byte[] key) throws GridException {
   return enabled && swapMgr.remove(spaceName, new GridSwapByteArray(key), null);
 }