原文章出處: http://blog.163.com/liwei1987821@126/blog/static/172664928201422133218356/
-
動態緩存 Cache緩存類
01 |
<?php |
02 |
$cache = Cache::getInstance( '緩存方式' , '緩存參數' ), |
03 |
/** |
04 |
*緩存方式包含: memcache;redis;file等 |
05 |
*緩存參數: 緩存有效期, 緩存列隊長度 |
06 |
*/ |
07 |
demo: |
08 |
//使用Xcache作為緩存方式,緩存有效期60秒。 |
09 |
$cache = Cache:getInstance( 'Xcache' , array ( 'expire' =>60)) |
10 |
$cache ->set( 'key' , $value ,3600); //存緩存 |
11 |
$cache ->get( 'key' ); //讀取緩存 |
12 |
$cache ->rm( 'key' ); //刪除緩存 |
13 |
|
14 |
?> |
2.快速緩存S
1 |
<?php |
2 |
demo: |
3 |
$fileName = MD5( "data" ); |
4 |
S( $fileName , $vaue ,3600); //存儲緩存 |
5 |
$value = S( $fileName ); //讀取緩存 |
6 |
S( $fileName ,NULL); //刪除緩存 |
7 |
?> |
3.簡單數據緩存F
1 |
<?php |
2 |
demo: |
3 |
$fileName =MD5( "data" ); |
4 |
F( $fileName , $value ); //存儲緩存 |
5 |
$value = F( $fileName ); //讀取文件緩存 |
6 |
F( $fileName ,NULL);刪除緩存文件 |
7 |
?> |