Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink 2.3: Clear cache through application
EclipseLink 2.3: Clear cache through application [message #1387727] Wed, 25 June 2014 13:58 Go to next message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hello,
In my application, there is facility to clear EclipseLink session cache, by calling the API.

The UI shows Descriptor names in a multi-select box and upon selection user can click to clear the cache.

The code that is written, to clear class-specific cache, is:
session.getIdentityMapAccessor().initializeIdentityMap(Class.forName(cacheClassName));


The code that is written, to clear complete cache, is:
session.getIdentityMapAccessor().initializeAllIdentityMaps();


Now the application is single-tier deployment i.e. complete web+business+persistence code in one EAR package.

With the above setup, still I am not seeing any change in cache.
I confirmed this by changing few attributes of the cached record, directly in database and then from the Web-page cleared the cache of the object. But the records are still remaining as old data.

Any clue?
Re: EclipseLink 2.3: Clear cache through application [message #1387733 is a reply to message #1387727] Wed, 25 June 2014 14:07 Go to previous messageGo to next message
Lukas JungmannFriend
Messages: 36
Registered: November 2013
Location: Prague, Czech Republic
Member
HI,

If I got it right calling those methods just invalidates objects in the cache and the cleanup is left up to the GC.
To verify this, run some query which should return entities you "cleared"/modified and check if the query hits the cache or the DB.

HTH,
--lukas
Re: EclipseLink 2.3: Clear cache through application [message #1387777 is a reply to message #1387733] Wed, 25 June 2014 15:22 Go to previous messageGo to next message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hello Lukas,
I have already checked it. Even after (seemingly) initializing/removing the elements from IdentityMap, the query in application still fetches the old data from cache.

e.g. in a table I have many records which have a status field value = 'Pending'; I used a DB client tool, to change the status field value = 'Complete', for all but 2 records. I committed the change in DB.

Now from the application I used the API call, to initialize resp. IdentityMap. But even after this it is picking up old records as 'Pending', which I already have changed to 'Complete'.
Re: EclipseLink 2.3: Clear cache through application [message #1387778 is a reply to message #1387733] Wed, 25 June 2014 15:23 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
initializeAllIdentityMaps removes all references to entities from the cache, which is slightly different from invalidation which keeps the references but marks them as needing to be refreshed so that the next query for them is forced to go to the database. The net effect is a query on the database, but invalidation is preferred because it saves having to rebuild objects, and keeps object identity throughout.

One other thing to check is that by calling session.getIdentityMapAccessor().initializeAllIdentityMap(s), you are clearing only that sessions identity maps. This is usually called on the server session and so affects the shared cache. This means that queries through the server session will go to the database, but there might be another level of cache, say within an EntityManager or UnitOfWork that may still have stale data if they contain managed objects read in previously. Check that the application isn't keeping around UOWs or EntityManagers for extended periods as they are meant to span the life of a transaction and reobtained as necessary.
Re: EclipseLink 2.3: Clear cache through application [message #1388162 is a reply to message #1387778] Thu, 26 June 2014 04:21 Go to previous message
Subhadip Chatterjee is currently offline Subhadip ChatterjeeFriend
Messages: 12
Registered: December 2013
Junior Member
Hi Chris,
Thanks for the hint. There's no UoW lying for an extended period, as the code shows [the application is in non-JPA style, so EntityManager is not configured]. I have now switched to invalidateAll() and invalidateClass(clazz, boolean) invocations, after seeing your post.

One more thing to ask.
Should I call validateCache() post any CRUD operations? If not, when is this method best used? Is it going to slow down the performance?

[Updated on: Thu, 26 June 2014 04:22]

Report message to a moderator

Previous Topic:Moxy map attribute that doesn't exist in the object model.
Next Topic:EclipseLink Performance (vs. OpenJPA)
Goto Forum:
  


Current Time: Fri Apr 26 04:34:13 GMT 2024

Powered by FUDForum. Page generated in 0.02936 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top