コード例 #1
0
  /**
   * @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()));
  }
コード例 #2
0
 /**
  * @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);
 }