/** * Convenience function * * @return void * @access public */ public static function key($string = '') { if (MiCache::$setting === null) { MiCache::config(); } $offset = $prefix = null; if (is_string($string)) { $prefix = $string . DS; } if (count(func_get_args() > 1 || !is_string($string))) { if (is_object($string)) { $string = func_get_args(); } if (is_object($string[0])) { $string[0] = !empty($string[0]->alias) ? $string[0]->alias : get_class($string[0]); } if (!$prefix && is_string($string[0])) { $prefix = $string[0] . DS; } $string = serialize($string); } $section = MiCache::sectionKey(MiCache::$section); $prefix .= $section . DS; if (empty(MiCache::$sectionPersistent)) { MiCache::$section = false; } $hash = md5(Configure::read('Config.language') . $string); $config = current(MiCache::config()); for ($i = 1; $i <= $config['dirLevels']; $i++) { $prefix .= substr($hash, $offset, $config['dirLength']) . DS; $offset = $i * $config['dirLength']; } return str_replace('.', '_', strtolower($prefix . $hash)); }