ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Narayanan, Gopal" <Gopal.Naraya...@bankofamerica.com>
Subject RE: Caching question (reply on JIRA-180)
Date Tue, 09 Aug 2005 15:09:54 GMT
	I was not able to locate the screen/link where I can close the
JIRA request. 
	This is my question.
	a. How do we know that the value fetched is from the database or
from a cache.
	   The way I tried to do this was 
		1. find the elapsed time to fetch data: If it is from
cache it is lower.
		2. shutdown the database: if it is still able to fetch
the data it implies it gets it from the cache.

	   Both 1 and 2, were satisfied when the sqlmap select  was 
		( All the data was stored in a list using queryForList)
		  <select id="getAllUsers" parameterClass="int"
resultClass="user" cacheModel="user-cache">
			    select first_name  as firstName,last_name as
lastName from myuser 

	   But when the query was changed to 
	  <select id="getUserByName" parameterClass="java.lang.String"
resultClass="user" cacheModel="user-cache">
		    select first_name  as firstName,last_name as
lastName from myuser  where last_name = #value#
	  both 1 and 2 were not satisfied. The times for 2 successive
queries (with the same #value#) were nearly the same.
	b. In the above case, since getUserByName uses the same
cacheModel as getAllUsers, will it get the data 
		from the cache built by getAllUsers ? ( assuming
getAllUsers is called first)
	c. The other question I have is: what does the size/cache-size
mean when we get a list of objects.
	   For eg for the getAllUsers case if we specify the size to be
50, will only 50 records/objects in the
	   returned list be cached?

Thanks again for your help.

-----Original Message-----
From: Sven.Boden [mailto:list123@pandora.be] 
Sent: Tuesday, August 09, 2005 6:05 AM
To: dev@ibatis.apache.org
Cc: Narayanan, Gopal
Subject: Caching question (reply on JIRA-180)


If you're not sure it's a bug don't make a JIRA request of it, ask it on
the mailing lists first. So I would suggest to close this JIRA request.

Now for your question (via the mailing list): 
- A hunch... only the objects returned from the database are cached, so
if you would have different values for #value# only the values you asked
before would be in the cache. Alternatively the flushing could occur
when you execute other database/iBATIS statements after your selection
which causes the cache to flush (dependent on your iBATIS setup,
normally you would flush on update/insert in dependent tables).
- A cache is not meant as database replacement, iBATIS assumes the
database is still up and running behind the cache.

If my hunch is not correct, can you provide more specific information on
your problem.

Sven Boden

>----- Oorspronkelijk bericht -----
>Van: gopal.narayanan (JIRA) [mailto:ibatis-dev@incubator.apache.org]
>Verzonden: dinsdag, augustus 9, 2005 03:55 AM
>Aan: ibatis-dev@incubator.apache.org
>Onderwerp: [jira] Created: (IBATIS-180) Caching question
>Caching question
>         Key: IBATIS-180
>         URL: http://issues.apache.org/jira/browse/IBATIS-180
>     Project: iBatis for Java
>        Type: Bug
>    Versions: 2.1.0    
> Environment: jdk1.4.2, windows xp
>    Reporter: gopal.narayanan
>I am not sure this is a bug.
>I am trying to use ibatis caching.
>Sql statements which do not have any parameters eg 
>    select fname,lname from users
>seem to work well under caching.
>This is how I tested, after the 1st call to the sql, the db was
shutdown, the next call returned the data from the cache. The time to
fetch was considerably lower, indicating that data was from the cache.
>But this test failed when the sql stmt was of the form select 
>fname,lname from users where lname = #value# It seemed that it always 
>need a db connection ( seems like the cache is flushed always) Is that 
>so? In that case can we not use ibatis caching?
>This message is automatically generated by JIRA.
>If you think it was sent incorrectly contact one of the administrators:
>   http://issues.apache.org/jira/secure/Administrators.jspa
>For more information on JIRA, see:
>   http://www.atlassian.com/software/jira

View raw message