Hi Nassar,
On Sat, Sep 25, 2010 at 2:40 PM, nasseria1 <[email protected]> wrote:

>
> Using the discussed methods I selected "cache.evictAll()" to clear the
> second level cache in OpenJPA, and I guess it worked, although I am not
> sure. First, is there any way to be sure that the cache is cleared in a
> simple case? for e.g. is there any count method to measure the
> functionality
> of evict() or evictAll() methods? To be more clear, we want to clear the
> second level cache in a certain way.
>

In the reference that Rick provided [1], there are a couple of ways to
determine whether the clear worked or not.  Since it sounds like you are
using JPA 2.0, then the easiest way is to just call the contains(Class, id)
method.  Or, you could use the cache statistics methods, also documented in
the reference.


> And finally, as we discussed, clearing the cache by evict() methods, has
> any
> side effect or any other practice that may be overlooked by programmers? I
> mean any aspect that can affect performance or even integrity of data?
>

The use of the second level cache is meant for performance reasons.  But,
there is always the chance that you could end up with stale data.
Especially if you have other applications affecting the database
simultaneously.  You can not affect the integrity of data by clearing a
cache.  But, depending on your application, you could affect performance.
Some experimentation and analysis will be required to get your usage
correct.

Good luck,
Kevin

[1]
http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_cache_use_JPA

Thanks for giving any idea,
> Nasser Fard
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/How-to-reset-OpenJPA-cache-tp5564799p5570602.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>

Reply via email to