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

io.lettuce.core.output.MapScanOutput Maven / Gradle / Ivy

Go to download

Advanced and thread-safe Java Redis client for synchronous, asynchronous, and reactive usage. Supports Cluster, Sentinel, Pipelining, Auto-Reconnect, Codecs and much more.

The newest version!
package io.lettuce.core.output;

import java.nio.ByteBuffer;

import io.lettuce.core.MapScanCursor;
import io.lettuce.core.codec.RedisCodec;

/**
 * {@link io.lettuce.core.MapScanCursor} for scan cursor output.
 *
 * @param  Key type.
 * @param  Value type.
 * @author Mark Paluch
 */
public class MapScanOutput extends ScanOutput> {

    private K key;

    private boolean hasKey;

    public MapScanOutput(RedisCodec codec) {
        super(codec, new MapScanCursor());
    }

    @Override
    protected void setOutput(ByteBuffer bytes) {

        if (!hasKey) {
            key = codec.decodeKey(bytes);
            hasKey = true;
            return;
        }

        V value = (bytes == null) ? null : codec.decodeValue(bytes);
        output.getMap().put(key, value);
        key = null;
        hasKey = false;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy