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 8838729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:04:59+00:00 2026-06-14T10:04:59+00:00

I just designed an admin console for a social networking website. My boss now

  • 0

I just designed an admin console for a social networking website. My boss now wants me to cache the results of several MySQL queries that build these results (for 24 hours). The site uses Memcached (with WordPress W3 total cache) and XCache. I wanted to know what’s the best way to do this.

Here is an example of one such query and how I am getting the results (basically I am returning aggregate stats on users, which means my results are fairly simple, eg:

//users who registered in last 365 days
$users_reg_365 = "select ID
from wp_users
where user_registered > NOW() - interval 365 day";

then use the wpdb query class to get the results:

$users_reg_365 = $wpdb->get_results($users_reg_365);

then display the result in the dashboard:

<li><?php echo "Total users who registered within last 365 days: <span class='sqlresult'>" . sizeof($users_reg_365) . "</span>"; ?></li>

My understanding of Memcached/XCache is that it basically stores strings, so would it make sense to just cache sizeof($users_reg_365)?

The last wrinkle is that our WordPress site uses W3 total cache, which leverages Memcached, and the boss asked me not to use Memcached but XCache instead, but I find the docs a bit confusing. What’s the best way to solve this problem? Can SQL itself be told to ‘remember’ certain queries like this, or is memory caching the way to go?

Thanks!

  • 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-14T10:05:00+00:00Added an answer on June 14, 2026 at 10:05 am

    You can find more about the differences of both here:
    Difference between Memcache, APC, XCache and other alternatives I've not heard of

    An example how you could

    <?php
    $m = new Memcached();
    $m->addServer('localhost', 11211);
    
    // cache 24hrs
    $cache_expire = 86400;
    
    
    // users is your key
    $users_reg_365 = $m->get('users_reg_365');
    if (empty($users_reg_365)) {
        $users_reg_365 = "select ID from wp_users where user_registered > NOW() - interval 365 day";
        $m->set('users_reg_365', $cache_expire);
    }
    

    If you need to exactly refresh the cache at middle night change the value of $cache_expire.

    You can refer to the full reference of memcached at
    http://www.php.net/manual/en/memcached.get.php

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

Sidebar

Related Questions

I just designed a portfolio website. I have a whole array of images that
I have recently just designed a website and was forced to call out a
I've just designed a large database by playing around in MS Access. Now that
I previously designed the website I'm working on so that I'd just query the
I just designed a simple For Loop using window form application. I would like
I was just reading how FaceBook designed their chat system, and it reads: and
I designed a page using Drupal 7 ( http://quaaoutlodge.com/drupal-7.14/ ). It looks just fine
I have just re-designed my iPhone app using Storyboard... questin is: how do I
I'm working on a project where the admin panel is just a shell that
Is such a thing possible? Did the people who designed REST just think they

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.