Code Monkey home page Code Monkey logo

Comments (4)

igoraguiar avatar igoraguiar commented on July 26, 2024 2

Of course.
I have a service with a method like this:

@Cacheable(value = "dataServiceCache.vehicleByLabelAndCompanyId", condition = "#result != null")
Vehicle findVehicleByLabelAndCompanyId(String label, long companyId) {

}

Now, with version 4, I have no way to do it using the condition closure.
I don't want to cache null values because, in the exemple, the vehicle may be inserted at some point, and the method will continue to return null.

Also, IMHO, I think it should be nice to keep this kind of compatibility with the previous version.

from grails-cache.

jameskleeh avatar jameskleeh commented on July 26, 2024

I don't understand the use case. Can you put together a more concrete example?

from grails-cache.

kgeis avatar kgeis commented on July 26, 2024

This could help with transitioning to newer versions of Grails that use ehcache 3. Version 2 allows null values, but 3 does not.

I think that Grails' Cacheable should try to follow Spring's. The solution would therefore be to add unless to mirror Spring's unless, in which "Unlike condition(), this expression is evaluated after the method has been called and can therefore refer to the result."

from grails-cache.

KoloritnijClap avatar KoloritnijClap commented on July 26, 2024

The problem wasn't solved. If somebody came here with the same problem: solution that works for me is to override Ehcache.java file and add
if(value == null) { putObserver.end(PutOutcome.NOOP); }
Into put method

from grails-cache.

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.