Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:00:58+00:00 2026-06-11T02:00:58+00:00

Inside a cffunction I have a query that I want to long cache by

  • 0

Inside a cffunction I have a query that I want to long cache by setting the cachedwitin to a big value. However, I also want to clear that cache under a few circumstances.

I’ve done this in a number of places, but in one of them the cache is never updated and I always get the original value if I ask it to give me the cached value.

The cfquery documentation states:

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

This is the case with the query, since it’s a single sql statement with no non-sql except the cfqueryparam; datasource and query name don’t change and username and password are not specified.

The relevant code is:

<!--- Long cache the query since the values rarely change, but allow the cache to be cleared. --->
<cfif Arguments.ClearCache EQ false>
    <cfset local.CachedWithin = CreateTimeSpan(7,0,0,0)>
<cfelse>
    <cfset local.CachedWithin = CreateTimeSpan(0,0,0,-1)>
</cfif>

<cfquery name="local.qryName" datasource="#Variables.DSN#" cachedwithin="#local.CachedWithin#">
    SELECT
        [User].[Name]
    FROM
        [User]
    WHERE
        [User].[UserID] = <cfqueryparam value="#Arguments.UserID#" cfsqltype="cf_sql_integer">
</cfquery>

Why does this work in other places, but not here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:01:00+00:00Added an answer on June 11, 2026 at 2:01 am

    There is an additional “sameness” requirement for cached queries that isn’t mentioned in the documentation. That note should end with:

    … password, and underlying data types of any cfqueryparam values.

    Change your code so that the Arguments.UserID is forced to a data type. In your case this can be accomplished by putting the following code before the cfquery:

    <!--- Make sure data types used in query are consistent --->
    <cfset local.UserID = Int(Arguments.UserID)>
    

    and change the cfqueryparam value to value="#local.UserID#".

    I’ve phrased the above as an omission in the documentation, but I suspect it’s a bug in CF9 instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside my Controller i have function that runs after user clicks on item, which
Inside my .aspx I have some JSON code that looks like this: function someFunctionName()
Inside a function I have created, I have this loop that checks if the
Inside a fragment, I have a button which I want to trigger the filling
Inside of my MVC application, I have a sub-folder named Admin that was Converted
Inside my accordion content i have rows of data that are loaded by ajax
Inside of an asp.net mvc partial view, I have an Ajax form that posts
Inside MySQL I have written a Procedure where I want to run a loop
Inside a container object, I have created a class Factory , that is responsible
Inside my android map I have three overlays looking like this: what I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.