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 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
- 请求一下,使用LinkedHashMap的方法存储本地缓存不失效,并且在使用清除本地缓存方法中,写锁没有释放 HOT 8
- 如何自定义 RedisCache ? HOT 1
- 高并发下,出现OOM以及其他异常 HOT 2
- 高并发下,出现OOM以及其他异常 HOT 1
- 关于本地缓存数据容量统计
- com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID:
- jetcache(RedisLettuceCache) GET error HOT 3
- 如何防止一级缓存穿透到二级缓存的呢? HOT 2
- jetcache(RedisLettuceCache) GET error HOT 3
- 报错jedis问题,不能使用lettuce吗? HOT 3
- 密码校验失败情况:Illegal character in authority at index 8: redis://r0&2o7^[email protected]:6379 HOT 1
- 在单元测试时,遇到无法更新缓存、删除缓存情况出现,想了解是什么原因? HOT 6
- cacheType指定了BOTH或者REMOTE时,不配置jetcache.remote再调用缓存方法能否不影响主业务 HOT 1
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.