Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | 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.';
}
		
		
comments powered by Disqus