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

  • Home
  • SEARCH
  • 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 546689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:53:38+00:00 2026-05-13T10:53:38+00:00

I need to implement cache for SQL queries. Say we have SELECT id,aa,bb FROM

  • 0

I need to implement cache for SQL queries.
Say we have SELECT id,aa,bb FROM table1 WHERE aa>1 and bb=12; – we want it to be cached.
Also, it may be SELECT id,aa,bb FROM table1 WHERE aa>25 and bb=11; or SELECT id,aa,bb FROM table2; of course.

Not a big deal — what really is a question is how to expire cache values better. On updates. Say, we added new row with INSERT ... or updated existing data with UPDATE ....
We need to expire all cache which had SELECTs values, as they may not be accurate any more.

How to do this better?

In the simplest case — we use the whole “SQL query” ask key in the cache. But at the moment of INSERT/UPDATE we have no idea which queries to expire (which keys?)

  • 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-05-13T10:53:38+00:00Added an answer on May 13, 2026 at 10:53 am

    One thing I’ve done before is to make a list of cache keys and store that in the cache as well.

    When I need to cache something I grab the list, add the key to it, and store it back in the cache. Then when I need to clear the cache for a particular set, I grab the list and remove every key in the list from the cache and remove the list from the cache.

    I get the impression this is how some cache libraries for example in NHibernate work too, but I’m not entirely sure about that.

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

Sidebar

Ask A Question

Stats

  • Questions 301k
  • Answers 301k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Django book suggests using os.path.join (and to use slashes… May 13, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer Attach an onclick handler to the images, which sets the… May 13, 2026 at 8:08 pm
  • Editorial Team
    Editorial Team added an answer ::Process.wait(0) May 13, 2026 at 8:08 pm

Related Questions

I have a script to extract certain data from a much bigger table, with
I'm storing a set of messages in a SQL table. Each message has a
I have a lot of existing code which uses raw ADO.NET (DbConnection, DbDataReader, etc).
we are planning to implement sql server 2005 cluster in next few months. i
I'm working on a CMS as my hobby project. Because I'm not paid for

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.