北京赛车 pk10开奖记录_Toyou热购彩票官网
香港高速VIP雲機房火爆上線啦!無需備案攬面秘,開通即用!配套《巔雲自助建站系統3.0》將帶給您飛一般的可視化拖拽建站體驗姆,歡迎免費體驗翠起。

來自phpguru得Php Cache類源碼

一佰互聯網站制作(www.yinxi.net) 發布日期 2019-04-30 09:22:31 瀏覽數: 22

Cache的作用不用說大家都知道咯,這些天也面試了一些人,發現很多人框架用多了,基礎都忘記了,你問一些事情,他總是說框架解決了,而根本不明白是怎麼回事,所以也提醒大家應該注意平時基礎知識的積累,之後對一些問題才能游刃有余.

群里也有些朋友對基礎知識很不屑,總說有能力就可以了,基礎知識考不出來什麼.對于這樣的觀點,我一直不苟同.
這個只是一點感概罷了. 下面看正題,介紹一個php的Cache類:

貼一下代碼吧:下面也有下載地址窮攫,其實很簡單魔擂呢,重要的是學習
復制代碼 代碼如下:
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is licensed under the Phpguru license. A quick summary is |
* | that for commercial use, there is a small one-time licensing fee to pay. For |
* | registered charities and educational institutes there is a reduced license |
* | fee available. You can read more at: |
* | |
* | http://www.phpguru.org/static/license.html |
* o------------------------------------------------------------------------------o
*/
/**
* Caching Libraries for PHP5
*
* Handles data and output caching. Defaults to /dev/shm
* (shared memory). All methods are static.
*
* Eg: (output caching)
*
* if (!OutputCache::Start("group", "unique id", 600)) {
*
* // ... Output
*
* OutputCache::End();
* }
*
* Eg: (data caching)
*
* if (!$data = DataCache::Get("group", "unique id")) {
*
* $data = time();
*
* DataCache::Put("group", "unique id", 10, $data);
* }
*
* echo $data;
*/
class Cache
{
/**
* Whether caching is enabled
* @var bool
*/
public static $enabled = true;
/**
* Place to store the cache files
* @var string
*/
protected static $store = "/dev/shm/";
/**
* Prefix to