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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:41:16+00:00 2026-05-28T18:41:16+00:00

I’m using Zend_Cache to cache data generated from a web service. However, in the

  • 0

I’m using Zend_Cache to cache data generated from a web service. However, in the event the web service does not respond, I want to display the outdated information and not leave a blank space.

According to the documentation, the answer is to pass the second argument to Zend_Cache_Core::load():

@param  boolean $doNotTestCacheValidity If set to true, the cache validity won't be tested

However, for every test I’ve done this always returns bool(false) for expired cache content.

Is there a way to force Zend_Cache to return the cached data for a given cache key, even when it has expired?

$cache_key = md5($url);
if ($out = $cache->load($cache_key)) {
  return $out;
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);

if ($output) {
  // Process...
  $cn_cache->save($out, $cache_key);
} else {
  // The query has timed out/web service not responded
  // We need to load the outdated cached content... but the following DOES NOT work
  return $cache->load($cache_key, true);

  // var_dump($cache->load($cache_key, true)); # false
}
  • 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-28T18:41:18+00:00Added an answer on May 28, 2026 at 6:41 pm

    I can’t think of a reliable way to do this other than to have a second cached version of the object that never expires. If you set a cache expiration time of X seconds on an object, there’s simply no way to guarantee that the object will still be there after X seconds.

    Example proposed workaround below…

    ...
    $cache_key_forever = sha1($url)
    if ($output) {
      // Process...
      $cn_cache->save($out, $cache_key);
      $cn_cache->save($out, $cache_key_forever, array(), null); // The "null" parameter is the important one here: save cache indefinitely
    } else {
      // The query has timed out/web service not responded
      // Load the infinitely persisted cache object
      return $cache->load($cache_key_forever);
    
      // var_dump($cache->load($cache_key, true)); # false
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
Does anyone know how can I replace this 2 symbol below from the string
I want to construct a data frame in an Rcpp function, but when I
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.