Menu

caching, doesn't

Anonymous
2004-12-01
2013-04-11
  • Anonymous

    Anonymous - 2004-12-01

    Ok, I'm stuck, and I have an uncomfortable feeling that the queries I *thought* were cached are, in fact, not.  Case in point:  The following query does NOT cache the results.  First, a snippet from my sqlmap.xml config file:

        <settings
            cacheModelsEnabled="true"
            enhancementEnabled="true"
            lazyLoadingEnabled="false"
            maxRequests="32"
            maxSessions="10"
            maxTransactions="5"
            useStatementNamespaces="true" />

    Next, the cache model definition from a sqlmap called "Campaigns":

        <cacheModel id="CampaignsCache" type="MEMORY" readOnly="false">
            <flushInterval minutes="30"/>
            <property name="reference-type" value="STRONG"/>
        </cacheModel>

    AND NOW, here's the select statement that I would think WOULD be cached:

        <select id="titles" resultClass="java.util.HashMap" cacheModel="CampaignsCache">
                select
                    Titles.id as "id",
                    Titles.name as "name",
                    Titles.description as "description",
                    Titles.img as "img",
                    CampaignTitles.position as "position"
                from
                    CampaignTitles, Titles
                where
                    CampaignTitles.campaignId = #value#
                    and CampaignTitles.titleId = Titles.id
                order by position
        </select>

    This statement is being called with a single Integer parameter as follows:

    // Get a list of titles for this campaign.  Should be cached.
    List titles = getSqlMapExecutor().queryForList("Campaigns.titles", new Integer(campaignId));

    So, what am I missing here?  If I execute my dao code such that it returns a list, and then use sql*plus to perform a manual update in the database, and then execute the dao again to retrieve the list, I'm seeing the change... but I shouldn't, because it should have been cached. 

    Any ideas?  What the heck?!

     
    • Anonymous

      Anonymous - 2004-12-01

      Oh, and I tried changing the cacheModel="CampaignsCache" in my select tag to cacheModel="Campaigns.CampaignsCache", thinking it might be a namespace issue.  Interesting enough, both seem to NOT work equally.  I would have expected one or the other would have generated an error at startup when the file is parsed.

       
    • rex

      rex - 2004-12-20

      Look in the docs about readOnly="false".  I think that may prevent the caching behavior you are expecting.

      Also, try using LRU instead of MEMORY.  Maybe your results are getting garbage collected. 

       
    • kum_karthigeyan

      kum_karthigeyan - 2005-08-23

      The same problem i had when i used Lru.
      Even the case is getting worse if u use serialize option along with readOnly="false"

       

Log in to post a comment.