Giter Site home page Giter Site logo

Comments (9)

areyouok avatar areyouok commented on June 8, 2024 1

我没有太看懂。

但你应该试试基于Cache API来实现复杂的逻辑,不是什么功能都一定要用注解实现。

from jetcache.

areyouok avatar areyouok commented on June 8, 2024 1

谢谢老师 另外多请教一下 如上实例,在触发 @CacheInvalidate 方法的时候 ,能否把其他服务实例(这里的服务指的是一个springboot应用,实例指的是不同的主机上面的应用进程)中的local级别缓存清理呢?老师,我看您在2.7.0.M1 版本的升级说明中说已经支持lettuce的通知实现跨实例的本地缓存失效机制?

这个已经支持了

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on June 8, 2024

这个是,但是就是第一个是“懒”,主要还是避免太多动作,想尽量简洁明了的实现,上面想说的是,“有一种根据条件来进行刷新” @Cache 所包裹的数据(可能是数据库、我们这边是三方系统返回的数据)

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on June 8, 2024

这是目前改造之后的做法,有上层来控制上面所需的条件重刷:

  @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.

areyouok avatar areyouok commented on June 8, 2024

框架不会实现所有的需求,除非

  1. 符合框架的定位
  2. 是普遍的需求
  3. 有合理的解决方案

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on June 8, 2024

谢谢老师 另外多请教一下 如上实例,在触发 @CacheInvalidate 方法的时候 ,能否把其他服务实例(这里的服务指的是一个springboot应用,实例指的是不同的主机上面的应用进程)中的local级别缓存清理呢?老师,我看您在2.7.0.M1 版本的升级说明中说已经支持lettuce的通知实现跨实例的本地缓存失效机制?

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on June 8, 2024

如果我提交一个 PR,“@CacheOrRefresh 搭配refCondition ”来实现上面的需求可以吗 老师

from jetcache.

areyouok avatar areyouok commented on June 8, 2024

如果我提交一个 PR,“@CacheOrRefresh 搭配refCondition ”来实现上面的需求可以吗 老师

这个需求很奇怪,我不想这么做。理由如上面的列出的 3 条

from jetcache.

Jiiiiiin avatar Jiiiiiin commented on June 8, 2024

收到 谢谢老师

from jetcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.