Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

6.9. Cache

# pear install Cache
		

文件缓存例子

		
<?php
require_once('Cache.php');

$cache = new Cache('file', array('cache_dir' => '/tmp/cache/') );

$id = $cache->generateID('test');

if ($data = $cache->get($id)) {
    print "Cache hit. Data: $data";

} else {
    $data = 'Hello world!!!';
    $cache->save($id, $data);
    print 'Cache miss.';
}