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