iyuohz / ehcache-spring-annotations

Automatically exported from code.google.com/p/ehcache-spring-annotations
0 stars 0 forks source link

Add attribute to @Cacheable to prevent caching of null values #50

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
EhCacheInterceptor.invokeCacheable() will cache a null return value from the 
methodInvocation.proceed() call.  This is causing a problem for our application 
in that we're using a null return when a DB object is not found, so caching the 
null prevents the DB from being queried again.  I realize that our issue should 
be solvable by putting a @TriggersRemove where the new object is written, but I 
don't really expect to need to flush the cache when creating new objects.  Can 
the @Cacheable annotation be enhanced with an attribute that will prevent nulls 
from being cached?

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by oland...@gmail.com on 7 Oct 2010 at 10:06

GoogleCodeExporter commented 9 years ago
Sounds like a great feature.

Original comment by eric.dalquist on 7 Oct 2010 at 11:38

GoogleCodeExporter commented 9 years ago
Simply add a flag "cacheNulls" ?

Original comment by davidkar...@gmail.com on 20 Oct 2010 at 12:57

GoogleCodeExporter commented 9 years ago
That sounds fine to me.

Original comment by oland...@gmail.com on 20 Oct 2010 at 10:02

GoogleCodeExporter commented 9 years ago
I miss that feature big time!
Absence of that feature actually prevents me from using @Cacheable

Original comment by bartosz....@gmail.com on 30 Nov 2010 at 12:33

GoogleCodeExporter commented 9 years ago

Original comment by eric.dalquist on 14 Jan 2011 at 2:49

GoogleCodeExporter commented 9 years ago

Original comment by eric.dalquist on 9 Mar 2011 at 5:40

GoogleCodeExporter commented 9 years ago

Original comment by eric.dalquist on 19 Apr 2011 at 9:09

GoogleCodeExporter commented 9 years ago
Added cacheNull attribute to @Cacheable

Original comment by eric.dalquist on 19 Apr 2011 at 9:22

GoogleCodeExporter commented 9 years ago

Original comment by eric.dalquist on 19 Apr 2011 at 9:22

GoogleCodeExporter commented 9 years ago
I am trying to figure out how to use the checkNull attribute, but am not able 
to get it to work. I am using version 1.1.3. 
@Cacheable(cacheName="noteCategoryCache", cacheNull=false)

The error I am getting is attribute checkNull is undefined.

Original comment by whutch...@comcast.net on 21 Jun 2011 at 6:15

GoogleCodeExporter commented 9 years ago
I am also facing same issue as comment 10 by whutch. I don't want ehcache to 
cache null values. cacheNull is giving undefined errors. Can you please suggest 
in which version this is implemented?
http://ehcache-spring-annotations.googlecode.com/svn/schema/ehcache-spring/ehcac
he-spring-1.1.xsd
I am using version 1.1.2.

This is giving lots of issues and I might have to look for other options for 
caching other than using this if this is not fixed. Early response is greatly 
appreciated. 

Original comment by saritha....@gmail.com on 14 Oct 2011 at 4:11

GoogleCodeExporter commented 9 years ago
If you notice the two release tags on this issue are 1.2 and 2.0. 1.2.0 is out, 
please use that version for this feature.

Original comment by eric.dalquist on 14 Oct 2011 at 4:13

GoogleCodeExporter commented 9 years ago
really appreciate your quick response

Original comment by saritha....@gmail.com on 14 Oct 2011 at 4:38

GoogleCodeExporter commented 9 years ago
i'm using ehcache 1.2.0, and like above i donnot want to cache null values 
either...
but my @cachable defination seems not to be working, can anyone help me here.

@Cacheable(cacheName = "WGPContractCache", keyGenerator = @KeyGenerator(name = 
"ListCacheKeyGenerator", properties = @Property(name = "includeMethod", value = 
"false")), cacheNull = false)

Original comment by meghna....@gmail.com on 20 Dec 2011 at 8:12

GoogleCodeExporter commented 9 years ago
is this working for anybody? doesn't work for me, please share...

Original comment by prakashb...@gmail.com on 30 May 2013 at 7:28