class GridRedisAppendCommandHandler extends GridRedisRestCommandHandler {
    /** Supported commands. */
    private static final Collection<GridRedisCommand> SUPPORTED_COMMANDS = U.sealList(
        APPEND
    );

    /** Position of the value. */
    private static final int VAL_POS = 2;

    /**
     * Handler constructor.
     *
     * @param log Logger to use.
     * @param hnd Rest handler.
     * @param ctx Kernal context.
     */
    public GridRedisAppendCommandHandler(IgniteLogger log, GridRestProtocolHandler hnd, GridKernalContext ctx) {
        super(log, hnd, ctx);
    }

    /** {@inheritDoc} */
    @Override public Collection<GridRedisCommand> supportedCommands() {
        return SUPPORTED_COMMANDS;
    }

    /** {@inheritDoc} */
    @Override public GridRestRequest asRestRequest(GridRedisMessage msg) throws IgniteCheckedException {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public ByteBuffer makeResponse(final GridRestResponse restRes, List<String> params) {
        if (restRes.getResponse() == null)
            return GridRedisProtocolParser.nil();

        if (restRes.getResponse() instanceof String) {
            int resLen = ((String)restRes.getResponse()).length();

            return GridRedisProtocolParser.toInteger(String.valueOf(resLen));
        }
        else
            return GridRedisProtocolParser.toTypeError("Operation against a key holding the wrong kind of value");
    }
}

        assert msg != null;

        if (msg.messageSize() < 3)
            throw new GridRedisGenericException("Wrong syntax");

        GridRestCacheRequest appendReq = new GridRestCacheRequest();
        GridRestCacheRequest getReq = new GridRestCacheRequest();

        String val = msg.aux(VAL_POS);

        appendReq.clientId(msg.clientId());
        appendReq.key(msg.key());
        appendReq.value(val);
        appendReq.command(CACHE_APPEND);
        appendReq.cacheName(msg.cacheName());

        Object resp = hnd.handle(appendReq).getResponse();
        if (resp != null && !(boolean)resp) {
            // append on non-existing key.
            GridRestCacheRequest setReq = new GridRestCacheRequest();

            setReq.clientId(msg.clientId());
            setReq.key(msg.key());
            setReq.value(val);
            setReq.command(CACHE_PUT);
            setReq.cacheName(msg.cacheName());

            hnd.handle(setReq);
        }

        getReq.clientId(msg.clientId());
        getReq.key(msg.key());
        getReq.command(CACHE_GET);
        getReq.cacheName(msg.cacheName());

        return getReq;
    
<methods>public abstract org.apache.ignite.internal.processors.rest.request.GridRestRequest asRestRequest(org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage) throws org.apache.ignite.IgniteCheckedException,public IgniteInternalFuture<org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage> handleAsync(org.apache.ignite.internal.util.nio.GridNioSession, org.apache.ignite.internal.processors.rest.protocols.tcp.redis.GridRedisMessage) ,public abstract java.nio.ByteBuffer makeResponse(org.apache.ignite.internal.processors.rest.GridRestResponse, List<java.lang.String>) <variables>protected final non-sealed org.apache.ignite.internal.GridKernalContext ctx,protected final non-sealed org.apache.ignite.internal.processors.rest.GridRestProtocolHandler hnd,protected final non-sealed org.apache.ignite.IgniteLogger log