Comments (3)
-
实现SerialPolicy接口
比如 TestPolicy -
注册Bean
@bean(name = "testPolicy")
public SerialPolicy testPolicy() {
// 省略
return testPolicy;
} -
配置 ,格式:valueEncoder: bean:testPolicy
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
local:
default:
type: linkedhashmap
keyConvertor: fastjson
remote:
test:
type: redisson
valueEncoder: bean:testPolicy
valueDecoder: bean:testPolicy
from jetcache.
我还是想用fastjson2进行value的序列化和反序列化,但是想存redis之前对value进行gzip压缩,减小数据的体积。但是看了看文档没有找到自定义序列化和反序列化的完整代码。麻烦给个步骤。 同时也问问有没有人是用gzip压缩的。效果好不好。不考虑kryo的原因是 如果新增 减少字段 kryo会报错。
源码参见:
com.alicp.jetcache.autoconfigure.JetCacheAutoConfiguration#springConfigProvider
com.alicp.jetcache.anno.support.SpringConfigProvider
com.alicp.jetcache.anno.support.DefaultSpringEncoderParser
com.alicp.jetcache.anno.support.DefaultSpringEncoderParser#parseBeanName
com.alicp.jetcache.anno.support.ConfigProvider#doInit
from jetcache.
api模式:
//初始化任务图相关数据的缓存配置
QuickConfig graphQc = QuickConfig.newBuilder(JetCacheConstant.PUBLISH_GRAPH_CACHE_NAME)
.expire(Duration.ofDays(PUBLISH_DATA_EXPIRE_TIME))
.cacheType(CacheType.BOTH)
// 本地缓存更新后,将在所有的节点中删除缓存,以保持强一致性
.valueDecoder(bytes -> GzipUtils.unGzip(new String(bytes, StandardCharsets.UTF_8)))
.valueEncoder(obj -> {
String gzip = GzipUtils.gzip(JSONObject.toJSONString(obj));
return gzip.getBytes();
})
.syncLocal(false)
.build();
使用起来感觉还行
from jetcache.
Related Issues (20)
- 序列化无法识别泛型 HOT 3
- JavaValueDecoder和JavaValueEncoder中均没有对inputstream和outstream 进行close操作,会不会有问题? HOT 2
- 文档有一处,编辑错误 HOT 1
- 配置了broadcastChannel ,syncLocal = true jvm缓存不失效 HOT 4
- cause by java.lang.NullPointerException: no decoder for identity number:-153049664 HOT 11
- 自定义项目my-jetcache-starter包后,jetcache无法使用starter包中的默认配置进行初始化 HOT 4
- SpringBoot3.2项目中@Cached注解key属性不支持参数名 HOT 2
- 当redis某个节点发生故障无法连接,导致项目无法启动
- 希望可以支持r2dbc,可以支持Reactor缓存
- spring项目引入jetcache启动报错 HOT 2
- 如何通过redis.lettuce连接带证书的redis?(redis非集群,HA模式的) HOT 1
- 反序列化异常 HOT 1
- redisson缓存通知,是否有规划增加redis stream方式 HOT 1
- 缓存一致性问题 HOT 1
- JedisCluster Pipeline 的支持? HOT 13
- @Cached、@CacheUpdate中的key、value是否像postCondition 、condition可以使用SpEL访问到#result对象? HOT 4
- Cached是否可以一次设置多个key? HOT 2
- AbstractCacheTest.penetrationProtectTest flaky
- api模式下 key过期时间配置
- @Cached注解使用key SpEL表达式,注解作用在接口上时失效。 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jetcache.