Ejemplo n.º 1
0
  private OffHeapValueHolder<V> newCreateValueHolder(K key, V value, long now) {
    Duration duration = expiry.getExpiryForCreation(key, value);
    if (Duration.ZERO.equals(duration)) {
      return null;
    }

    if (duration.isForever()) {
      return new OffHeapValueHolder<V>(value, now, OffHeapValueHolder.NO_EXPIRE);
    } else {
      return new OffHeapValueHolder<V>(value, now, safeExpireTime(now, duration));
    }
  }
Ejemplo n.º 2
0
  private OffHeapValueHolder<V> newUpdatedValueHolder(
      K key, V value, OffHeapValueHolder<V> existing, long now) {
    Duration duration = expiry.getExpiryForUpdate(key, existing.value(), value);
    if (Duration.ZERO.equals(duration)) {
      return null;
    }

    if (duration == null) {
      return new OffHeapValueHolder<V>(
          value, now, existing.expirationTime(OffHeapValueHolder.TIME_UNIT));
    } else if (duration.isForever()) {
      return new OffHeapValueHolder<V>(value, now, OffHeapValueHolder.NO_EXPIRE);
    } else {
      return new OffHeapValueHolder<V>(value, now, safeExpireTime(now, duration));
    }
  }