《XiunoPHP 4.0开发手册》全局变量$cache
XiunoPHP全局变量$cache
【功能】默认缓存实例
如果配置文件设置了缓存相关的配置,则框架会自动实例化一个 Cache 类。
一般不用直接使用这个变量,除非在升级,转换需要多个连接的时候。
一般用 cache_set(), cache_get() 函数来操作缓存。
使用时,需要配置好 Cache 服务和 PHP 相关的 Cache 扩展,目前支持:
apc|xcache|memcached|redis|mysql 。
如果为单机,建议使用 xcache,速度比较快。
【定义】 文件:xiunophp/xiunophp.php 大约 77 行:
$cache = !empty($conf['cache']) ? cache_new($conf['cache']) : NULL;
【用例】
<?php
$conf = include './conf.php';
include './xiunophp/xiunophp.php';
$cache->set('key1', 'value1');
$cache->get('key1');
?>
【conf.php】
<?php
return array (
// -------------> xiunophp 依赖的配置
'cache'=> array(
'enable' => TRUE,
'type'=> 'xcache', // apc|xcache|memcached|redis|mysql
'memcached'=> array (
'host'=>'localhost',
'port'=>'11211',
),
'redis'=> array (
'host'=>'localhost',
'port'=>'6379',
),
),
// 可以配置为 linux 下的 /dev/shm ,通过内存缓存临时文件
'tmp_path' => './',
'log_path' => './'
);
?>
稿源:TechTMT.Com综合整理!
分类:文章
标签:
编辑:tmt
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。文章版权归原作者所有,内容不代表本站立场!
免责声明:
阁下应知本站所提供的内容不能做为操作依据。本站作为信息内容发布平台,不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考!
如文中内容影响到您的合法权益(含文章中文字、图片等),请及时联系本站,我们会及时删除处理。
相关文章:
- 《XiunoPHP 4.0开发手册》全局变量$starttime
- 《XiunoPHP 4.0开发手册》全局变量$ip
- 《XiunoPHP 4.0开发手册》全局变量$ajax
- 《XiunoPHP 4.0开发手册》全局变量$errstr
- 《XiunoPHP 4.0开发手册》数据库函数db_insert()
- 《XiunoPHP 4.0开发手册》数据库函数db_replace()
- 《XiunoPHP 4.0开发手册》数据库函数db_update()
- 《XiunoPHP 4.0开发手册》数据库函数db_find_one()
- 《XiunoPHP 4.0开发手册》数据库函数db_find()
- 《XiunoPHP 4.0开发手册》数据库函数db_count()
- 《XiunoPHP 4.0开发手册》数据库函数db_connect()
- 《XiunoPHP 4.0开发手册》数据库函数db_exec()
- 《XiunoPHP 4.0开发手册》数据库函数db_new()
- 《XiunoPHP 4.0开发手册》数组增强array_value()
- 《XiunoPHP 4.0开发手册》数组增强array_addslashes()
- 《XiunoPHP 4.0开发手册》数组增强array_htmlspecialchars()
- 《XiunoPHP 4.0开发手册》数组增强array_assoc_slice()
- 《XiunoPHP 4.0开发手册》数组增强arrlist_cond_orderby()
- 《XiunoPHP 4.0开发手册》数组增强arrlist_key_values()
- 《XiunoPHP 4.0开发手册》数组增强arrlist_chunk()