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

com.lambdaworks.redis.output.KeyValueOutput Maven / Gradle / Ivy

// Copyright (C) 2011 - Will Glozer.  All rights reserved.

package com.lambdaworks.redis.output;

import com.lambdaworks.redis.KeyValue;
import com.lambdaworks.redis.codec.RedisCodec;
import com.lambdaworks.redis.protocol.CommandOutput;

import java.nio.ByteBuffer;

/**
 * Key-value pair output.
 *
 * @param  Key type.
 * @param  Value type.
 *
 * @author Will Glozer
 */
public class KeyValueOutput extends CommandOutput> {
    private K key;

    public KeyValueOutput(RedisCodec codec) {
        super(codec, null);
    }

    @Override
    public void set(ByteBuffer bytes) {
        if (bytes != null) {
            if (key == null) {
                key = codec.decodeKey(bytes);
            } else {
                V value = codec.decodeValue(bytes);
                output = new KeyValue(key, value);
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy