redissonClient.getBucket("key01", Commonlang3RedissonSerializer.INSTANCE).get()

自定义序列化方式

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import org.apache.commons.lang3.SerializationUtils;
import org.redisson.client.codec.BaseCodec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;


public class Commonlang3RedissonSerializer extends BaseCodec {
    public static final Commonlang3RedissonSerializer INSTANCE = new Commonlang3RedissonSerializer();

    private final Encoder encoder = o -> {
        byte[] serialize = SerializationUtils.serialize((Serializable) o);
        return Unpooled.wrappedBuffer(serialize);
    };

    private final Decoder<Object> decoder = new Decoder<Object>() {
        public Object decode(ByteBuf buf, State state) {
            ByteBufInputStream byteBufInputStream = new ByteBufInputStream(buf);
            return  SerializationUtils.deserialize(byteBufInputStream);
        }
    };


    @Override
    public Decoder<Object> getValueDecoder() {
        return decoder;
    }

    @Override
    public Encoder getValueEncoder() {
        return encoder;
    }
}