Menu

How does checking cache work?

2004-11-15
2013-04-11
  • Jerome Jacobsen

    Jerome Jacobsen - 2004-11-15

    Consider the following:

    <cacheModel id="product-cache" implementation="LRU">
    <flushInterval hours="24"/>
    <property name="size" value="1000"/>
    </cacheModel>

    <statement id="getProductList" parameterClass="int" cacheModel="product-cache">
    <![CDATA[
    SELECT * FROM product
    WHERE id > #value#
    ]]>
    </statement>

    Assume the #value# for my first query was 10 and it returned the following:

    PRODUCT ID=10, DESC="Spring Framework Book"
    PRODUCT ID=11, DESC="Oracle DB License"
    PRODUCT ID=12, DESC="iPod 20GB"

    Now assume the #value# for my next query for the session is 11.  What happens?  Are items 11 and 12 retrieved from the cache?  How would the cache implementation know to return these?  Or does it?

     
    • Brandon Goodin

      Brandon Goodin - 2004-11-16

      caching is query and parameter based. So, if you have 2 queries that use the same sql statement and different parameters the cache will store the 2 sets of results seperately.

      Brandon

       

Log in to post a comment.