You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Joe Wolf <jo...@compsciresources.com> on 2006/03/03 19:29:44 UTC

Flushing caches

Is there any way to programmatically flush a cache?  I'm getting ready to head down the road where I'll just call some bogus statement in my SQL map that's in my cache's flushOnExecute list.  I was wondering if there was a more straightforward way.  Thanks.

-Joe  
CompSci Resources, LLC

Re: Flushing caches

Posted by Sven Boden <li...@pandora.be>.
Custom CacheModels are still open as 
http://issues.apache.org/jira/browse/IBATIS-137. What you can already do 
now is write your own CacheController and specify the full class name 
where you would normally put LRU, MEMORY, ...
But even then it will be very hard to implement a kind of object 
identity cache (in a general way), what you would want to have is ORMish 
like Hibernate does it... and that doesn't match up with how iBATIS works.

iBATIS just maps ResultSets to objects, it doesn't keep track itself of 
object identities/states, you can't specify e.g. to save all 
"dirty/changed" objects.

Regards,
Sven

Reuben Firmin wrote:

> Clinton sez, in the message referenced in that bug: "This is where 
> custom, or domain specific, caching comes into play." Apologies if 
> this is in TFM, but is there a way to get Ibatis to use your own cache 
> implementation? Or is this something that you'd have to write at your 
> DAO level?
>
>
> Sven Boden wrote:
>
>>
>> No that's not possible, and probably will never be. There's a JIRA 
>> open for it http://issues.apache.org/jira/browse/IBATIS-222 which I 
>> would like to close as "won't fix" ;-).
>>
>> The problem is that iBATIS has no concept of object identity. If you 
>> look at the caching code, caching is on the "level of the 
>> query/ResultSet", if you have iBATIS e.g. return 2 lists of objects, 
>> it may be well be that what for you is 1 and the same object may be 
>> cached twice (once in every list). Object identity is a concept that 
>> doesn't mix with Sql Mapping.
>>
>> Regards,
>> Sven
>>
>> Reuben Firmin wrote:
>>
>>> I've been wondering about a related question -- is there any way to 
>>> flush a cache for only one particular object?
>>>
>>> I'd like to be able to say "I've only modified this Foo bean, so 
>>> flush it, but keep the other Foo beans that are in the cache". Are 
>>> there problems associated with this that I'm missing?
>>>
>>>
>>> Sven Boden wrote:
>>>
>>>>
>>>> Following should do the trick:
>>>>
>>>> sqlMapClient.flushDataCache();
>>>> or
>>>> sqlMapClient.flushDataCache("cache id");
>>>>
>>>> Look in the com.ibatis.sqlmap.client.SqlMapClient interface.
>>>>
>>>> Regards,
>>>> Sven
>>>>
>>>> Joe Wolf wrote:
>>>>
>>>>> Is there any way to programmatically flush a cache?  I'm getting 
>>>>> ready to head down the road where I'll just call some bogus 
>>>>> statement in my SQL map that's in my cache's flushOnExecute list.  
>>>>> I was wondering if there was a more straightforward way.  Thanks.
>>>>>
>>>>> -Joe  CompSci Resources, LLC
>>>>>  
>>>>>
>>>


Re: Flushing caches

Posted by Reuben Firmin <re...@cnet.com>.
Clinton sez, in the message referenced in that bug: "This is where 
custom, or domain specific, caching comes into play." Apologies if this 
is in TFM, but is there a way to get Ibatis to use your own cache 
implementation? Or is this something that you'd have to write at your 
DAO level?


Sven Boden wrote:

>
> No that's not possible, and probably will never be. There's a JIRA 
> open for it http://issues.apache.org/jira/browse/IBATIS-222 which I 
> would like to close as "won't fix" ;-).
>
> The problem is that iBATIS has no concept of object identity. If you 
> look at the caching code, caching is on the "level of the 
> query/ResultSet", if you have iBATIS e.g. return 2 lists of objects, 
> it may be well be that what for you is 1 and the same object may be 
> cached twice (once in every list). Object identity is a concept that 
> doesn't mix with Sql Mapping.
>
> Regards,
> Sven
>
> Reuben Firmin wrote:
>
>> I've been wondering about a related question -- is there any way to 
>> flush a cache for only one particular object?
>>
>> I'd like to be able to say "I've only modified this Foo bean, so 
>> flush it, but keep the other Foo beans that are in the cache". Are 
>> there problems associated with this that I'm missing?
>>
>>
>> Sven Boden wrote:
>>
>>>
>>> Following should do the trick:
>>>
>>> sqlMapClient.flushDataCache();
>>> or
>>> sqlMapClient.flushDataCache("cache id");
>>>
>>> Look in the com.ibatis.sqlmap.client.SqlMapClient interface.
>>>
>>> Regards,
>>> Sven
>>>
>>> Joe Wolf wrote:
>>>
>>>> Is there any way to programmatically flush a cache?  I'm getting 
>>>> ready to head down the road where I'll just call some bogus 
>>>> statement in my SQL map that's in my cache's flushOnExecute list.  
>>>> I was wondering if there was a more straightforward way.  Thanks.
>>>>
>>>> -Joe  CompSci Resources, LLC
>>>>  
>>>>
>>
>>

Re: Flushing caches

Posted by Sven Boden <li...@pandora.be>.
No that's not possible, and probably will never be. There's a JIRA open 
for it http://issues.apache.org/jira/browse/IBATIS-222 which I would 
like to close as "won't fix" ;-).

The problem is that iBATIS has no concept of object identity. If you 
look at the caching code, caching is on the "level of the 
query/ResultSet", if you have iBATIS e.g. return 2 lists of objects, it 
may be well be that what for you is 1 and the same object may be cached 
twice (once in every list). Object identity is a concept that doesn't 
mix with Sql Mapping.

Regards,
Sven

Reuben Firmin wrote:

> I've been wondering about a related question -- is there any way to 
> flush a cache for only one particular object?
>
> I'd like to be able to say "I've only modified this Foo bean, so flush 
> it, but keep the other Foo beans that are in the cache". Are there 
> problems associated with this that I'm missing?
>
>
> Sven Boden wrote:
>
>>
>> Following should do the trick:
>>
>> sqlMapClient.flushDataCache();
>> or
>> sqlMapClient.flushDataCache("cache id");
>>
>> Look in the com.ibatis.sqlmap.client.SqlMapClient interface.
>>
>> Regards,
>> Sven
>>
>> Joe Wolf wrote:
>>
>>> Is there any way to programmatically flush a cache?  I'm getting 
>>> ready to head down the road where I'll just call some bogus 
>>> statement in my SQL map that's in my cache's flushOnExecute list.  I 
>>> was wondering if there was a more straightforward way.  Thanks.
>>>
>>> -Joe  CompSci Resources, LLC
>>>  
>>>
>
>


Re: Flushing caches

Posted by Reuben Firmin <re...@cnet.com>.
I've been wondering about a related question -- is there any way to 
flush a cache for only one particular object?

I'd like to be able to say "I've only modified this Foo bean, so flush 
it, but keep the other Foo beans that are in the cache". Are there 
problems associated with this that I'm missing?


Sven Boden wrote:

>
> Following should do the trick:
>
> sqlMapClient.flushDataCache();
> or
> sqlMapClient.flushDataCache("cache id");
>
> Look in the com.ibatis.sqlmap.client.SqlMapClient interface.
>
> Regards,
> Sven
>
> Joe Wolf wrote:
>
>> Is there any way to programmatically flush a cache?  I'm getting 
>> ready to head down the road where I'll just call some bogus statement 
>> in my SQL map that's in my cache's flushOnExecute list.  I was 
>> wondering if there was a more straightforward way.  Thanks.
>>
>> -Joe  CompSci Resources, LLC
>>  
>>

Re: Flushing caches

Posted by Sven Boden <li...@pandora.be>.
Following should do the trick:

sqlMapClient.flushDataCache();
or
sqlMapClient.flushDataCache("cache id");

Look in the com.ibatis.sqlmap.client.SqlMapClient interface.

Regards,
Sven

Joe Wolf wrote:

>Is there any way to programmatically flush a cache?  I'm getting ready to head down the road where I'll just call some bogus statement in my SQL map that's in my cache's flushOnExecute list.  I was wondering if there was a more straightforward way.  Thanks.
>
>-Joe  
>CompSci Resources, LLC
>  
>