Minify_Cache_Memcache::isValid PHP Méthode

isValid() public méthode

Does a valid cache entry exist?
public isValid ( string $id, integer $srcMtime ) : boolean
$id string cache id
$srcMtime integer mtime of the original source file(s)
Résultat boolean exists
    public function isValid($id, $srcMtime)
    {
        return $this->_fetch($id) && $this->_lm >= $srcMtime;
    }

Usage Example

function test_Minify_Cache_Memcache()
{
    $prefix = 'Minify_Cache_Memcache : ';
    if (!function_exists('memcache_set')) {
        return;
    }
    $mc = new Memcache();
    if (!@$mc->connect('localhost', 11211)) {
        return;
    }
    $data = str_repeat(md5('testing'), 160);
    $id = 'Minify_test_cache';
    $cache = new Minify_Cache_Memcache($mc);
    assertTrue(true === $cache->store($id, $data), $prefix . 'store');
    assertTrue(strlen($data) === $cache->getSize($id), $prefix . 'getSize');
    assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid');
    ob_start();
    $cache->display($id);
    $displayed = ob_get_contents();
    ob_end_clean();
    assertTrue($data === $displayed, $prefix . 'display');
    assertTrue($data === $cache->fetch($id), $prefix . 'fetch');
}
All Usage Examples Of Minify_Cache_Memcache::isValid