Esempio n. 1
0
 final NotifyingFuture<V> putIfAbsentAsync(
     K key,
     V value,
     long lifespan,
     TimeUnit lifespanUnit,
     long maxIdle,
     TimeUnit maxIdleUnit,
     EnumSet<Flag> explicitFlags,
     ClassLoader explicitClassLoader) {
   assertKeyNotNull(key);
   InvocationContext ctx =
       getInvocationContextWithImplicitTransaction(explicitFlags, explicitClassLoader);
   ctx.setUseFutureReturnType(true);
   PutKeyValueCommand command =
       commandsFactory.buildPutKeyValueCommand(
           key,
           value,
           lifespanUnit.toMillis(lifespan),
           maxIdleUnit.toMillis(maxIdle),
           ctx.getFlags());
   command.setPutIfAbsent(true);
   return wrapInFuture(executeCommandAndCommitIfNeeded(ctx, command));
 }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 final V putIfAbsent(
     K key,
     V value,
     long lifespan,
     TimeUnit lifespanUnit,
     long maxIdleTime,
     TimeUnit idleTimeUnit,
     EnumSet<Flag> explicitFlags,
     ClassLoader explicitClassLoader) {
   assertKeyNotNull(key);
   InvocationContext ctx =
       getInvocationContextWithImplicitTransaction(explicitFlags, explicitClassLoader);
   PutKeyValueCommand command =
       commandsFactory.buildPutKeyValueCommand(
           key,
           value,
           lifespanUnit.toMillis(lifespan),
           idleTimeUnit.toMillis(maxIdleTime),
           ctx.getFlags());
   command.setPutIfAbsent(true);
   return (V) executeCommandAndCommitIfNeeded(ctx, command);
 }