Minify_Cache_Memcache::getSize PHP Méthode

getSize() public méthode

Get the size of a cache entry
public getSize ( string $id ) : integer
$id string cache id
Résultat integer size in bytes
    public function getSize($id)
    {
        if (!$this->_fetch($id)) {
            return false;
        }
        if (function_exists('mb_strlen') && (int) ini_get('mbstring.func_overload') & 2) {
            return mb_strlen($this->_data, '8bit');
        } else {
            return strlen($this->_data);
        }
    }

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::getSize