Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializing error when using retrieve($key, true) #23

Open
smcjones opened this issue Feb 10, 2016 · 1 comment
Open

Serializing error when using retrieve($key, true) #23

smcjones opened this issue Feb 10, 2016 · 1 comment

Comments

@smcjones
Copy link

Thanks for this wonderful and simple caching library. It's exactly what I need!

Just FYI, this notice occurs on line 105 of cache.class.php in my version
of PHP, 5.6.14.

The fix is to only serialize when $type == 'data'. My quick fix was this:

 /**
   * Retrieve cached data by its key
   * 
   * @param string $key
   * @param boolean [optional] $timestamp
   * @return string
   */
  public function retrieve($key, $timestamp = false) {
    $cachedData = $this->_loadCache();
    (false === $timestamp) ? $type = 'data' : $type = 'time';
    if (!isset($cachedData[$key][$type])) return null; 

    if ($type == 'time') {
        return $cachedData[$key][$type];
    }
    return unserialize($cachedData[$key][$type]);
  }
@XerraX
Copy link

XerraX commented Aug 19, 2016

saved me some time, still using this script ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants