Giter Site home page Giter Site logo

Comments (2)

mp911de avatar mp911de commented on May 25, 2024

Redis cannot store objects by their Java identity as the storage happens externally by serializing the key into bytes. Also, a JPA specification has no means of being identifiable in any way since it has no key or other details attached. In your case, it is merely a lambda.

If you want to keep using a Specification as key, I suggest that you create a subinterface (or a wrapper type) that accepts a Specification and a String (key) in your application. Then you register a Converter through RedisCacheConfiguration.configureKeyConverters(…) using the key from your Specification wrapper to create a meaningful Redis key.

Let me know how this goes.

from spring-data-redis.

trcoelho avatar trcoelho commented on May 25, 2024

Hi @mp911de !
Thanks for your reply!

Yes, that pretty much that I did. Instead mark repository method as @Cacheable, I implemented a new layer that wraps repository calls and this layer I marked as @Cacheable.

So instead we have:

Controller -> Service -> Repository(@Cacheable)

We have:

Controller -> Service -> CacheableRepository(@Cacheable) -> Repository

That would work better as CacheableRepository has one single responsability while Repository remains with database access responsability, in my perspective. :)

Anyways, appreciate your attention as well your suggestion.

Let me know if you have any question.

Take care!

from spring-data-redis.

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.