use of org.apache.geode.redis.internal.ByteArrayWrapper in project geode by apache.
the class GetExecutor method executeCommand.
@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
if (command.getProcessedCommand().size() < 2) {
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETEXECUTOR));
return;
}
ByteArrayWrapper key = command.getKey();
checkDataType(key, RedisDataType.REDIS_STRING, context);
ByteArrayWrapper wrapper = r.get(key);
if (wrapper == null) {
command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
return;
} else {
command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), wrapper.toBytes()));
}
}
use of org.apache.geode.redis.internal.ByteArrayWrapper in project geode by apache.
the class GetSetExecutor method executeCommand.
@Override
public void executeCommand(Command command, ExecutionHandlerContext context) {
List<byte[]> commandElems = command.getProcessedCommand();
Region<ByteArrayWrapper, ByteArrayWrapper> r = context.getRegionProvider().getStringsRegion();
if (commandElems.size() < 3) {
command.setResponse(Coder.getErrorResponse(context.getByteBufAllocator(), ArityDef.GETSET));
return;
}
ByteArrayWrapper key = command.getKey();
checkAndSetDataType(key, context);
byte[] newCharValue = commandElems.get(VALUE_INDEX);
ByteArrayWrapper newValueWrapper = new ByteArrayWrapper(newCharValue);
ByteArrayWrapper oldValueWrapper = r.get(key);
r.put(key, newValueWrapper);
if (oldValueWrapper == null) {
command.setResponse(Coder.getNilResponse(context.getByteBufAllocator()));
} else {
command.setResponse(Coder.getBulkStringResponse(context.getByteBufAllocator(), oldValueWrapper.toBytes()));
}
}
Aggregations