ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Tan <erictan...@yahoo.com.sg>
Subject Re: Cached list from queryForList() ...
Date Wed, 15 Nov 2006 09:40:12 GMT
Hi Larry,

Please ignore my previous posting. 

My understanding of the serializable read/write cache was totally wrong. 

After digging through the source code, I realized that the object is serialized to a byte
array and this byte array is then cached up in memory. Subsequent queries will retrieve new
copies through the deserialization of this byte array. Therefore there is only one cached
"object" for all sessions.

On the other hand, using just a read/write cache without serialization will create a cached
object per session (ie. cacheKey is appened with session id). If the maxSessions setting is
high and there are many requests, this will result in many similar cached objects. Memory
usage will be high due to the many duplicates. In addition, each session will need to retrieve
its data from the database for the first query.

For both cases, each query will return a copy of the cached object and modifications are made
to this copy and not the cached object.


----- Original Message ----
From: Eric Tan <erictankok@yahoo.com.sg>
To: user-java@ibatis.apache.org
Sent: Wednesday, 8 November 2006 12:26:15 AM
Subject: Re: Cached list from queryForList() ...

Hi Larry,

Doh! Forgot about that feature. Thanks...

I think a serializable read/write cache is what I need. A different cache object for each

A few questions:

1. Where are the serialized cached objects physically stored?

2. When does the serialized cached object per session get cleaned up? 

3. Can the same cacheModel store different objects? For example, MyObj and List of MyObj.

In other words, can getProduct and getProductList statements use the same cacheModel?

4. Using serializable read/write cache: 
User 1 calls getProductList.
10 products are retrieved and cached as a List within iBatis.
User 1 gets a copy of this List with 10 products. This copy serves as a
 cached list for User 1's session.
User 1 removes 3 products from his list copy.
Subsequent getProductList calls by User 1 will always return his cached copy of 7 products.

User 2 calls getProductList.
Since there is a cached list of 10 products,User 2 gets a copy of this list with 10 products.
This copy serves as a cached list for User 2's session.
User 2 removes 7 products from his list copy.
Subsequent getProductList calls by User 2 will always return his cached copy of 3 products.

Is this how the serializable read/write cache works?


----- Original Message ----
From: Larry Meadors <lmeadors@apache.org>
To: user-java@ibatis.apache.org
Sent: Monday, 6 November 2006 11:29:55 PM
Subject: Re: Cached list from queryForList() ...

Yes: Make sure that the cache is not marked as read-only.


On 11/6/06, Eric Tan <erictankok@yahoo.com.sg> wrote:
> Hi,
> I was testing Spring Acegi Security's AfterInvocationProviderManager which
> deals with domain object instance security (ACL).
> With ibatis caching enabled and queryForList(), I realised that returned
> result list was the actual cached list.
> With AfterInvocationProviderManager performing object filtering of the
> returned list, unauthorised objects in the returned
 list were removed. Which
> means the objects were actually removed from the cached list. Subsequent
> invocations of the same queryForList() would return a smaller list.
> Is there any way to configure ibatis to return a copy of the cached list
> instead of the actual cached list?
> My current workaround is to return a shallow copy of the cached list.
> Thanks,
> Eric
>  ________________________________
>  What will the world find in 2020?
>  Leave a part of your 2006 in the Yahoo! Time Capsule. Contribute now!

What is the internet to you?
Contribute to the Yahoo! Time Capsule and be a part of internet history.

Yahoo! Singapore Answers 
Real people. Real questions. Real answers. Share what you know at http://answers.yahoo.com.sg
View raw message