com.github.rxyor.spring.boot.redisson.FastJsonCodec Maven / Gradle / Ivy
package com.github.rxyor.spring.boot.redisson;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.rxyor.common.util.string.CharSequenceUtil;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufUtil;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import org.redisson.client.codec.BaseCodec;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder;
/**
*
*
*
*
* @author liuyang
* @date 2019/12/31 周二 00:13:00
* @since 1.0.0
*/
public class FastJsonCodec extends BaseCodec {
public static final FastJsonCodec INSTANCE = new FastJsonCodec();
private final Encoder encoder = in -> {
String json = JSON.toJSONString(in, SerializerFeature.WriteClassName,
SerializerFeature.DisableCircularReferenceDetect);
CharBuffer charBuffer = CharBuffer.wrap(CharSequenceUtil.string2CharArray(json));
return ByteBufUtil.encodeString(ByteBufAllocator.DEFAULT, charBuffer, Charset.forName("utf-8"));
};
private final Decoder
© 2015 - 2025 Weber Informatics LLC | Privacy Policy