Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] How to clear Cache

Ok, thanks for this additional information.
But I have tested this now unfortunately unsuccessful:
- I search some objects in on the search page
- I see the objects in the IdentityMaps
- modify the values direct in the DB-Table
- search again for the same objects. The modification does not appear
(correct!)
- I fire: aSession.getIdentityMapAccessor().invalidateAll();
- search the same objects
 => The modifications do not appear (in-correct?!)

Does EclipseLink fetch the data from the DB, if the object is marked as
in-valid and updates the values of the object?

Some background information:
- EclipseLink 1.0.2
- The objects are read-only: Query.setHint(QueryHints.READ_ONLY,
HintValues.TRUE);



Gordon Yorke-2 wrote:
> 
> InvalidateAll does not actually remove the instances from the cache like 
> initializeAllIdentityMaps does.  Invalidation marks the cached objects 
> as being invalid and they will be refreshed when queried for.  They are 
> the same instances but will have different state.  It is important that 
> the same instances are used to ensure referential integrity (the ability 
> to navigate through java references from multiple nodes in your Entity 
> tree and still be able to gain access to the same instance)
> 
> --Gordon
> Joe Mc. wrote:
>> Hi Gordon,
>>
>> yes right #invalidateAll() is the right Method; however, the call of this
>> method has no effect
>> I print always the maps out
>> (aSession.getIdentityMapAccessor().printIdentityMaps())
>>
>> I have a search site, where it's possible to find some objects. 
>> If I use 
>> aSession.getIdentityMapAccessor().invalidateAll();
>> the maps seem to be empty, however if I return to the search page and
>> fire a
>> selection. I see the same outputs with the same objects (hashcodes)
>> Does invalidateAll() flushs the cache immediately? 
>>
>> I have the same effect with the other invalidate*-Methods
>> (invalidateClass
>> etc.)
>>
>> That's the reason, why I use 
>> aSession.getIdentityMapAccessor().initializeAllIdentityMaps();
>>
>> To Cache-Coordination:
>> Yes, that will be the better solution. But I have at the moment not the
>> time
>> in the projects to switch to this feature.
>>
>>
>> Thanks
>> Joe
>>
>>
>>
>>
>>
>> Gordon Yorke-2 wrote:
>>   
>>> Initializing the identity maps in a running system can lead to hard to 
>>> diagnose errors.  IdentityMapAccessor.invalidateAll()  and the other 
>>> invalidation APIs are the recommended approach.  Have you looked at 
>>> Cache Coordination ( 
>>> http://wiki.eclipse.org/Introduction_to_Cache_(ELUG)#Cache_Coordination_2 
>>> ) to automatically handle the notification for you.
>>> --Gordon
>>>
>>> Joe Mc. wrote:
>>>     
>>>> Alright, my solution is:
>>>>
>>>> - I am using a SessionCustomizer 
>>>> - adding a SessionEventAdapter
>>>> - override preExecuteQuery
>>>> - call Session.getIdentityMapAccessor().initializeAllIdentityMaps()
>>>>
>>>> Codesnippet:
>>>>
>>>> public void customize(Session session) throws Exception {
>>>>   
>>>>    SessionEventAdapter evtListener = new SessionEventAdapter() {
>>>>       
>>>>       @Override
>>>>       public void preExecuteQuery(SessionEvent event) {
>>>>           Session aSession = event.getSession();
>>>>           
>>>>           // check if cache invalidation is necessary....
>>>>           // if yes:
>>>>          
>>>> aSession.getIdentityMapAccessor().initializeAllIdentityMaps();
>>>>       }
>>>>    }
>>>> }
>>>>
>>>>
>>>>
>>>> Open Questions:
>>>> - is preExecuteQuery the right place?
>>>> - Does any better solution exist?
>>>>
>>>>
>>>> Thanks
>>>>
>>>> Mc.Joe
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Joe Mc. wrote:
>>>>   
>>>>       
>>>>> Hi everybody,
>>>>>
>>>>> I trying to provide a functionality to delete the whole cache, to
>>>>> support
>>>>> the possibility to refresh the objects in the cache.
>>>>> How is the best practice to flush the whole cache?
>>>>>
>>>>> I have the following use case:
>>>>> - 2 separate Applications on different servers
>>>>> - Both use JPA Eclipselink
>>>>> - Application A reads the objects, I am using SoftWeak
>>>>> - Application B modifies sometimes the data
>>>>>
>>>>> desired is, that Application B gives Application A a signal (details
>>>>> are
>>>>> here irrelevant), if he modified the data
>>>>> Application A will flush his cache, if he gets this event.
>>>>>
>>>>> Now the question is: Does any API exists to flush the (whole) cache?
>>>>>
>>>>> Thanks in advance
>>>>>
>>>>> Mc.Joe
>>>>>
>>>>>     
>>>>>         
>>>>   
>>>>       
>>> _______________________________________________
>>> eclipselink-users mailing list
>>> eclipselink-users@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>
>>>
>>>     
>>
>>   
> 
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-clear-Cache-tp23567622p23640573.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top