> For the complete documentation index, see [llms.txt](https://bing.gitbook.io/phper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bing.gitbook.io/phper/php/3.-kuang-jia/codeigniter/huan-cun-ji-zhi.md).

# 缓存机制

### 目录

System/libraries/Cache

### 自行封装

```
public static function getRs()
{
    $config = CI::config('redis');
    $redis = new \Redis();
    try {
        if ($redis->connect($config['host'], $config['port'])) {
            $redis->select((int)$config['db']);
        }
    } catch (\Exception $e) {
        return false;
    }
    return $redis;
}
```
