Question

I'm trying to cache a stored procedure. I have ColdFusion 10 downloaded and it is running on a Railo 4 server. I have the database connection setup in my Railo Admin ( a default cache ) and according to the Adobe docs I only need to use the cachedWithin attribute and it should get cached. However, it does not and I know this for sure because my pages take over 10 sec. to load!

I tried dynamically caching it using the cfcache tags around the stored procedures, but this kept caching the entire page which I do not want to cache. CachePut and CacheGet also work, but my code is way to complicated to effectively accommodate them.

Super confused.

Here is the relevant code:

<cfstoredproc datasource="#XXX#" procedure="XXX" cachedWithin="#CreateTimeSpan(0,3,0,0)#">
                <cfprocparam type="In" value="#IDate#" cfsqltype="CF_SQL_TIMESTAMP">
                <cfprocparam type="In" value="12" cfsqltype="CF_SQL_INTEGER">
                <cfprocparam type="In" value="1" cfsqltype="CF_SQL_BIT">
                <cfprocresult name="DeptQuery">
</cfstoredproc>

UPDATE: It turns out that the stored procedure is not the one taking all that time! And I've got it cache at last! But I'm confused about how it's doing it since I'm caching 1000s of variants of the same stored procedure over multiple pages (with each page alone having multiple stored procs) and all I've specified is a cachedWithin param. How does it know which procedure is which when it pulls them up to the view?

No correct solution

OTHER TIPS

You're passing in (what looks like) a date/time. Query caching is based on the arguments to the query (or more specifically, the SQL that would be used). I'm assuming you're passing in different date/time valus each time. Each different date/time value would have its own cached result, unless you're just passing in the same date value each time?

e.g. these would be treated as two different objects for caching:

<cfstoredproc datasource="#XXX#" procedure="XXX" cachedWithin="#CreateTimeSpan(0,3,0,0)#">
     <cfprocparam type="In" value="2013-06-13 09:00:00" cfsqltype="CF_SQL_TIMESTAMP">
</cfstoredproc>

<cfstoredproc datasource="#XXX#" procedure="XXX" cachedWithin="#CreateTimeSpan(0,3,0,0)#">
     <cfprocparam type="In" value="2013-06-13 10:00:00" cfsqltype="CF_SQL_TIMESTAMP">
</cfstoredproc>    

From the documentation:

To use cached data, the current query must use same SQL statement, data source, query name, user name, and password.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top