array( 'adapter' => $apc ? 'Apc' : 'File', 'strategies' => $apc ? array() : array('Serializer'), 'scope' => $apc ? md5(LITHIUM_APP_PATH) : null ) )); /** * Apply * * Applies caching to neuralgic points of the framework but only when we are running * in production. This is also a good central place to add your own caching rules. * * A couple of caching rules are already defined below: * 1. Cache paths for auto-loaded and service-located classes. * 2. Cache describe calls on all connections that use a `Database` based adapter. * * @see lithium\core\Environment * @see lithium\core\Libraries */ if (!Environment::is('production')) { return; } Filters::apply('lithium\action\Dispatcher', 'run', function($params, $next) { $cacheKey = 'core.libraries'; if ($cached = Cache::read('default', $cacheKey)) { $cached = (array) $cached + Libraries::cache(); Libraries::cache($cached); } $result = $next($params); if ($cached != ($data = Libraries::cache())) { Cache::write('default', $cacheKey, $data, '+1 day'); } return $result; }); Filters::apply('lithium\action\Dispatcher', 'run', function($params, $next) { foreach (Connections::get() as $name) { if (!(($connection = Connections::get($name)) instanceof Database)) { continue; } Filters::apply($connection, 'describe', function($params, $chain) use ($name) { if ($params['fields']) { return $next($params); } $cacheKey = "data.connections.{$name}.sources.{$params['entity']}.schema"; return Cache::read('default', $cacheKey, array( 'write' => function() use ($params, $next) { return array('+1 day' => $next($params)); } )); }); } return $next($params); }); ?>