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.';
}