缓存 Cache
优质
小牛编辑
143浏览
2023-12-01
swoole框架目前支持5种Cache适配器,可以配置apps/configs/cache.php
的type来设定不同类型的Cache
Memcache
使用memcache
缓存数据,配置示例:
$cache['master'] = array(
'type' => 'Memcache',
'use_memcached' => true, //使用memcached扩展
'compress' => true, //启用压缩
'servers' => array(
array(
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 100,
'persistent' => true,
),
array(
'host' => '127.0.0.1',
'port' => 11211,
'weight' => 100,
'persistent' => true,
),
),
);
Redis
使用redis
服务器缓存数据,底层基于redis->setex
实现。
DBCache
使用数据库表作为缓存存储
FileCache
文件系统缓存。