/** * Constructor */ public function __construct() { $CI =& get_instance(); $CI->load->helper('file'); !isset($CI->cfg) && $CI->load->library('cfg'); $path = implode(DIRECTORY_SEPARATOR, Cfg::_system('cache', 'file')) . DIRECTORY_SEPARATOR; $this->set_cache_path($path == '' ? APPPATH . 'cache/' : $path); }
public function __construct() { $this->CI =& get_instance(); $this->CI->load->library('cfg'); $this->configs = \Cfg::_system('model', 'cache'); if ($this->configs['driver'] == 'redis') { $this->CI->load->library("redis"); $this->redis = new \CI_Redis(array('no_cfg_cache' => true)); $this->configs['driver'] = $this->redis->getStatus($error) ? 'redis' : 'file'; } }
<?php if (!defined('BASEPATH')) { exit('No direct script access allowed'); } /** * @author OA Wu <*****@*****.**> * @copyright Copyright (c) 2016 OA Wu Design */ $model['recycle']['limit'] = 100; $model['recycle']['origin_id'] = 'origin_id'; $model['cache']['is_enabled'] = false; $model['cache']['driver'] = 'file'; // 'file', 'redis' $model['cache']['file_path'] = Cfg::_system('cache', 'model'); $model['cache']['redis_main_key'] = array('model'); $model['cache']['d4_cache_time'] = 300; // sec
function config($arguments, $forder = 'setting', $is_cache = true) { $data = null; if ($levels = array_filter($arguments)) { $key = '_config_' . $forder . '_|_' . implode('_|_', $levels); if ($is_cache && ($CI =& get_instance()) && !isset($CI->cache)) { $CI->load->driver('cache', array('adapter' => 'apc', 'backup' => 'file')); } if ((!$is_cache || !($data = $CI->cache->file->get($key, FCPATH . implode(DIRECTORY_SEPARATOR, Cfg::_system('cache', 'config')) . DIRECTORY_SEPARATOR))) && ($config_name = array_shift($levels)) && is_readable($path = utilitySameLevelPath(FCPATH . APPPATH . 'config' . DIRECTORY_SEPARATOR . $forder . DIRECTORY_SEPARATOR . $config_name . EXT))) { include $path; $data = ($config_name = ${$config_name}) ? _config_recursive($levels, $config_name) : null; $is_cache && $CI->cache->file->save($key, $data, 60 * 60, FCPATH . implode(DIRECTORY_SEPARATOR, Cfg::_system('cache', 'config')) . DIRECTORY_SEPARATOR); } } return $data; }