Comments (9)
我没有太看懂。
但你应该试试基于Cache API来实现复杂的逻辑,不是什么功能都一定要用注解实现。
from jetcache.
谢谢老师 另外多请教一下 如上实例,在触发 @CacheInvalidate 方法的时候 ,能否把其他服务实例(这里的服务指的是一个springboot应用,实例指的是不同的主机上面的应用进程)中的local级别缓存清理呢?老师,我看您在2.7.0.M1 版本的升级说明中说已经支持lettuce的通知实现跨实例的本地缓存失效机制?
这个已经支持了
from jetcache.
这个是,但是就是第一个是“懒”,主要还是避免太多动作,想尽量简洁明了的实现,上面想说的是,“有一种根据条件来进行刷新” @Cache
所包裹的数据(可能是数据库、我们这边是三方系统返回的数据)
from jetcache.
这是目前改造之后的做法,有上层来控制上面所需的条件重刷:
@Override
public SecPagingResType<RecordRespListOdrDtlType> entry(@NonNull final RecordsQryType qryType) {
// step
if (qryType.isFirstPage()) {
recordsInfraclI.clearCacheData(qryType);
}
// step
final BaseSecOrgRecordCmplxOdrType<RecordRespListOdrDtlType> recordCmplxOdrType = recordsInfraclI.qryPayRecords(qryType);
// step paging
return SecPagingResType.newInstance(
qryType.getPageNum(),
qryType.getPageSize(),
recordCmplxOdrType.getTotalCount(),
recordCmplxOdrType.getOdrDetails()
);
}
public static final String CACHE_NAME_FOR_PAYMENT_RECORDS_EXT_SVC_QRY_PAY_RECORDS = "PaymentRecordsExtSvc.qryPayRecords:";
public static final String CACHE_BIZ_KEY_FOR_QRY_TYPE_MOBILE_PHONE = "#qryType.mobilePhone";
@Cached(
name = CACHE_NAME_FOR_PAYMENT_RECORDS_EXT_SVC_QRY_PAY_RECORDS,
key = CACHE_BIZ_KEY_FOR_QRY_TYPE_MOBILE_PHONE,
expire = 180,
cacheType = CacheType.BOTH,
localLimit = 2000,
localExpire = 120
)
@CachePenetrationProtect
@Override
public BaseSecOrgRecordCmplxOdrType<RecordRespListOdrDtlType> qryPayRecords(@NonNull final RecordsQryType qryType) {
final RecordsQryPkg qryPkg = RecordsQryPkg.newInstance(qryType);
final RecordsQryResPkg resPkg = this.recordsQryResPkgImbTransportClient.execute(qryPkg);
logger.info("qryPayRecords do qry end");
return resPkg.getSecOrgRecordCmplxOdrType();
}
@CacheInvalidate(
name = CACHE_NAME_FOR_PAYMENT_RECORDS_EXT_SVC_QRY_PAY_RECORDS,
key = CACHE_BIZ_KEY_FOR_QRY_TYPE_MOBILE_PHONE
)
@Override
public void clearCacheData(@NonNull final RecordsQryType qryType) {}
from jetcache.
框架不会实现所有的需求,除非
- 符合框架的定位
- 是普遍的需求
- 有合理的解决方案
from jetcache.
谢谢老师 另外多请教一下 如上实例,在触发 @CacheInvalidate 方法的时候 ,能否把其他服务实例(这里的服务指的是一个springboot应用,实例指的是不同的主机上面的应用进程)中的local级别缓存清理呢?老师,我看您在2.7.0.M1 版本的升级说明中说已经支持lettuce的通知实现跨实例的本地缓存失效机制?
from jetcache.
如果我提交一个 PR,“@CacheOrRefresh 搭配refCondition ”来实现上面的需求可以吗 老师
from jetcache.
如果我提交一个 PR,“@CacheOrRefresh 搭配refCondition ”来实现上面的需求可以吗 老师
这个需求很奇怪,我不想这么做。理由如上面的列出的 3 条
from jetcache.
收到 谢谢老师
from jetcache.
Related Issues (20)
- 序列化无法识别泛型 HOT 3
- JavaValueDecoder和JavaValueEncoder中均没有对inputstream和outstream 进行close操作,会不会有问题? HOT 2
- 文档有一处,编辑错误 HOT 1
- 配置了broadcastChannel ,syncLocal = true jvm缓存不失效 HOT 3
- 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.