Memcache lifetime

Looking around this problem i can't understand why it doesn't validate lifetime.

Testing with this code, also tries different values of lifetime like 1, etc:

        var_dump($cacheData->exists($cacheKey, 0)); // true
        $widgets = $cacheData->get($cacheKey, 0);

        if ($widgets === null){
            $widgets = Content::find(array(
                "page_id = '{$this->id}'",
                "order" => "widget_order",
            ));

            $cacheData->save($cacheKey, serialize($widgets), 0);
        }
        else{
            $widgets = unserialize($widgets);
        }

P.S. APC also has this problem.... only FIlebased cache works well...



83.4k

What is the unexpected behavior? Do you want to make the cache never expires or always expires?

Also if you're using Phalcon\Cache\Frontend\Data you don't need to serialize/unserialize the data before storing/retrieving them in the backend.

Ooh thanks =)... after some hours of work i didn't realize that for mamcache (and APC) 'zero' is 'never'...Sorry.. xD =)

And thanks for tip about serializing.. i missed this, too =)