spring-data-redis 使用 protobuf进行序列化和反序列
2017-01-06 17:30
936 查看
这是spring配置,protostuff有一个特点就是你反序列化的时候需要指定反序列化的类型Class,而如果按常规spring-data-redis规范,只能实现RedisSerializer接口,其中反序列化接口T deserialize(byte[] bytes) throws SerializationException;无法指定Class,所以换个思路,我们在调用redisTemplate操作的时候不是直接放对象而是直接放序列化后的byte[],而反序列化的时候获取byte[]再通过protostuff转为对应的class。注意一点是enableDefaultSerializer这个属性要置为false,并且不要配置valueSerializer因为如果不设置该属性RedisTemplate初始化的时候会指定默认的序列化也就是JdkSerializationRedisSerializer来作为序列化和反序列化。
相关文章推荐
- C#使用Protocol Buffer(ProtoBuf)进行对象的序列化与反序列化
- 使用protoBuf进行序列化和反序列化
- Beetle使用Protobuf.net进行对象序列化传输
- spring-data-redis 使用过程中需要注意的一点(序列化选择)
- 使用spring-data-redis进行对redis的操作,封装的一些操作方法
- spring-data-redis使用自定义序列化数据 使用 protobuf
- springboot使用protostuff进行序列化和反序列化整合redis的redisTemplate的各种方法的写法
- Android下使用Protobuf进行序列化
- C# 使用 protobuf 进行对象序列化与反序列化
- [置顶] 使用protobuff 进行网络序列化和反序列传输实例
- Android下使用Protobuf进行序列化
- Unity使用protobuf-net进行二进制序列化与反序列化
- ASP.NET Core 使用 Redis 和 Protobuf 进行 Session 缓存
- spring-data-redis使用jdk序列化时increment的异常
- 使用Spring-data进行Redis操作
- 使用spring-session-data-redis来进行session共享
- SpringBoot整合Netty并使用Protobuf进行数据传输(附工程)
- Simple-Spring-Memcached使用Protobuf序列化Java对象
- asp.net core 使用 Redis 和 Protobuf 进行 Session 缓存
- 【protobuf】 3.使用protobuf-csharp-port进行序列化和反序列化