首先,在配置文件中有如下配置:

# /data/config.php

$config['setting']['cache'] = 'mysql';

然后,在框架入口中会加载缓存相关文件:

# /framework/bootstrap.inc.php

if (!in_array($_w['config']['setting']['cache'], array('mysql', 'memcache', 'redis'))) {
	$_w['config']['setting']['cache'] = 'mysql';
}
load()->func('cache');

然后,在缓存方法中会加载实际使用的缓存类:

# /framework/function/cache.func.php

load()->func('cache.' . cache_type());

function cache_type() {
	$cache_type = strtolower($_w['config']['setting']['cache']);

	// 实例化 memcache 或 redis
	// 连接 cache 对应的服务器
	// ...

	return $cache_type;
}

最后,在缓存类中提供了读写缓存的方法:

# /framework/function/cache.xxx.func.php

function cache_read($key) {}
function cache_write($key, $data, $expire = 0) {}
function cache_delete($key) {}
function cache_clean($prefix = '') {}