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

The Archive Base Latest Questions

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

I’m using Memcached in conjunction with my PHP web app written in CodeIgniter. I

  • 0

I’m using Memcached in conjunction with my PHP web app written in CodeIgniter. I utilize this Memcached library https://github.com/tomschlick/memcached-library When I cache data, I give it an expiration time of 7200, or 2 hours.

Snippet of a model query:

$result = $this->memcached_library->get(md5($sql));
if (!$result) {
     $cursor = $this->db->query($sql);
     $result = $cursor->row();
     $this->memcached_library->set(md5($sql), $result, 7200);
}
return $result;

Cool, this works for setting data into Memcached. I can see the results, all is working well. The problem comes in that after 2 hours after placing this data into Memcached.

From my understanding, when executing the get function, Memcached should recognize that the cached data has hit past its expired date and thus marks it as invalid (not necessarily deleting it from memory however). When the PHP call to get the data, it should return false, which will then in turn cause my if statement to be evaluated as true and refetch the data and set the data in Memcached yet again.

However, it seems as if Memcached never says the data is invalid, and the same old data is in there from before the 2 hour expiration limit. If I manually call flush on Memcached (invalidating all data in the cache), the data is set into Memcached properly yet again, but we run into the same 2 hour expiration limit problem yet again.

  • 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-17T02:11:32+00:00Added an answer on June 17, 2026 at 2:11 am

    From memcached manual:

    EXPIRATION TIME:
    If it’s non-zero (either Unix time or offset in seconds from
    current time), it is guaranteed that clients will not be able to
    retrieve this item after the expiration time arrives (measured by
    server time).

    So this should be NULL after expiration time. If it happens otherwise you have found a bug in Memcached or this library. Are you sure you are using “Memcached” and not “Memcache”. From sources of the lib you linked:

    $this->client_type = class_exists('Memcache') ? "Memcache" : (class_exists('Memcached') ? "Memcached" : FALSE);
    // ...
    log_message('debug', "Memcached Library: $this->client_type Class Loaded");
    

    Also i see this library is using local cache that is ignoring the expiry date:

    if(isset($this->local_cache[$this->key_name($key)]))
    {
        return $this->local_cache[$this->key_name($key)];
    }
    

    So if your php script is running as daemon for a long period of time no actual Memcached request will be sent.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I am using Paperclip to handle profile photo uploads in my app. They upload
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.