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

    /** Value position in Redis message. */
    private static final int VAL_POS = 2;

    /**
     * Handler constructor.
     *
     * @param log Logger to use.
     * @param hnd Rest handler.
     * @param ctx Kernal context.
     */
    public GridRedisSetCommandHandler(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>}

    /**
     * Attempts to set expiration when EX or PX parameters are specified.
     *
     * @param restReq {@link GridRestCacheRequest}.
     * @param params Command parameters.
     * @throws GridRedisGenericException When parameters are not valid.
     */
    private void setExpire(GridRestCacheRequest restReq, List<String> params) throws GridRedisGenericException {
        Long px = longValue("px", params);
        Long ex = longValue("ex", params);

        if (px != null)
            restReq.ttl(px);
        else if (ex != null)
            restReq.ttl(ex * 1000L);
    }

    /** {@inheritDoc} */
    @Override public ByteBuffer makeResponse(final GridRestResponse restRes, List<String> params) {
        Object resp = restRes.getResponse();

        if (resp == null)
            return GridRedisProtocolParser.nil();

        return (!(boolean)resp ? GridRedisProtocolParser.nil() : GridRedisProtocolParser.oKString());
    }
}

        assert msg != null;

        if (msg.messageSize() < 3)
            throw new GridRedisGenericException("Wrong number of arguments");

        // check if an atomic long with the key exists (related to incr/decr).
        IgniteAtomicLong l = ctx.grid().atomicLong(msg.key(), 0, false);

        if (l != null) {
            try {
                l.close();
            }
            catch (IgniteException ignored) {
                U.warn(log, "Failed to remove atomic long for key: " + msg.key());
            }
        }

        GridRestCacheRequest restReq = new GridRestCacheRequest();

        restReq.clientId(msg.clientId());
        restReq.key(msg.key());

        restReq.command(CACHE_PUT);
        restReq.cacheName(msg.cacheName());

        restReq.value(msg.aux(VAL_POS));

        if (msg.messageSize() >= 4) {
            List<String> params = msg.aux();

            // get rid of SET value.
            params.remove(0);

            if (U.containsStringCollection(params, "nx", true))
                restReq.command(CACHE_PUT_IF_ABSENT);
            else if (U.containsStringCollection(params, "xx", true))
                restReq.command(CACHE_REPLACE);

            setExpire(restReq, params);
        }

        return restReq;
    
<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