Giter Club home page Giter Club logo

Comments (4)

barsifedron avatar barsifedron commented on July 3, 2024

So I am sure to properly understand the question, are you refering to this type of caching ?
https://springhow.com/spring-boot-redis-cache/

from candid-cqrs.

tebuco avatar tebuco commented on July 3, 2024

first apologize for my late reply.
yes but only on requests, because the commands do not need is it possible
and do not pollute the domain as in example https://springhow.com/spring-boot-redis-cache/
and create a cahe decorator for all requests thank you

from candid-cqrs.

barsifedron avatar barsifedron commented on July 3, 2024

You could do something like as described in this PR

This is a "proof of concept" pull request only.
But if you run the application with ./gradlew clean bootRun you should see it working.

It shows how one could theoritically use a single middleware to enable spring @Cacheable features for all incoming queries.

WARNING

  • As it is here, there is no time expiration for the cache. This need to be configured at the cache provider level as explained here. I will leave it to you to configure the REDIS.
  • Also, I suspect you need to be disciplined and always override hashCode() and equals() on your Query objects if you want to avoid any colision issues with this. Use it at your own risks.

Another way to do it, should you want something more fine grained, would be to use @Cacheable directly on your CommandHandlers and QueryHandlers, the same way you would do with a traditional Spring service. The ones on your Command handlers would evict the cache and the ones on your query handlers register the result in the cache.

from candid-cqrs.

tebuco avatar tebuco commented on July 3, 2024

thank you for your help I will be inspired by this to do it with redis

from candid-cqrs.

Related Issues (7)

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.