title: Caching a stored procedure in ColdFusion
body: <p>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 <code>cachedWithin</code> 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! </p>
  
  <p>I tried dynamically caching it using the <code>cfcache</code> tags around the stored procedures, but this kept caching the entire page which I do not want to cache. <code>CachePut</code> and <code>CacheGet</code> also work, but my code is way to complicated to effectively accommodate them. </p>
  
  <p>Super confused. </p>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>&lt;cfstoredproc datasource="#XXX#" procedure="XXX" cachedWithin="#CreateTimeSpan(0,3,0,0)#"&gt;
                  &lt;cfprocparam type="In" value="#IDate#" cfsqltype="CF_SQL_TIMESTAMP"&gt;
                  &lt;cfprocparam type="In" value="12" cfsqltype="CF_SQL_INTEGER"&gt;
                  &lt;cfprocparam type="In" value="1" cfsqltype="CF_SQL_BIT"&gt;
                  &lt;cfprocresult name="DeptQuery"&gt;
  &lt;/cfstoredproc&gt;
  </code></pre>
  
  <p>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?</p>