All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.hotrod.impl.operations.SetIfAbsentOperation Maven / Gradle / Ivy

There is a newer version: 14.0.32.Final
Show newest version
package org.infinispan.hotrod.impl.operations;

import org.infinispan.api.common.CacheWriteOptions;
import org.infinispan.hotrod.impl.DataFormat;
import org.infinispan.hotrod.impl.logging.LogFactory;
import org.infinispan.hotrod.impl.protocol.HotRodConstants;
import org.jboss.logging.BasicLogger;

import io.netty.buffer.ByteBuf;

/**
 * Implements "putIfAbsent" operation as described in  Hot Rod
 * protocol specification.
 *
 * @since 14.0
 */
public class SetIfAbsentOperation extends AbstractPutIfAbsentOperation {

   private static final BasicLogger log = LogFactory.getLog(SetIfAbsentOperation.class);

   public SetIfAbsentOperation(OperationContext operationContext,
         K key, byte[] keyBytes, byte[] value,
         CacheWriteOptions options,
         DataFormat dataFormat) {
      super(operationContext, key, keyBytes, value, options, dataFormat);
   }

   @Override
   void completeResponse(ByteBuf buf, short status) {
      boolean wasSuccess = HotRodConstants.isSuccess(status);
      if (log.isTraceEnabled()) {
         log.tracef("Returning from setIfAbsent: %s", wasSuccess);
      }
      complete(wasSuccess);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy