コード例 #1
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     if (!$this->_cache || $this->_cache === TRUE) {
         $this->_cache = CachePlugin::init();
     }
 }
コード例 #2
0
 /**
  * Initialize cache.
  *
  * @param string $type
  * @param int $lifetime
  * @return Zend_Cache_Core|Zend_Cache_Frontend
  */
 public static function init($type = 'Core', $lifetime = 7200)
 {
     if (self::$_cache === null) {
         $frontendOptions = array('lifetime' => $lifetime, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_PATH . '/../cache/', 'hashed_directory_level' => 1, 'hashed_directory_perm' => 0777, 'cache_file_perm' => 0777);
         self::$_cache = Zend_Cache::factory($type, 'File', $frontendOptions, $backendOptions);
     }
     return self::$_cache;
 }
コード例 #3
0
 /**
  * Get Form from Cache!
  *
  * @param string $form
  * @param AbstractModel|array $values
  * @return AbstractForm
  */
 public static function get($form = '', $values = null)
 {
     if (empty($form)) {
         return null;
     }
     $cache = CachePlugin::init('Core', is_null($values) ? null : 7200);
     $name = 'form_' . $form;
     if (!is_null($values)) {
         $name .= '_' . md5(print_r($values, true));
     }
     if (isset(self::$_forms[$name])) {
         return self::$_forms[$name];
     } else {
         if (($object = $cache->load($name)) === false) {
             $class = ucwords(preg_replace('/(_|\\-)/', ' ', $form));
             $class = str_replace(' ', '', $class) . 'Form';
             $object = new $class($values);
             $cache->save($object, $name);
         }
     }
     self::$_forms[$name] = $object;
     return self::$_forms[$name];
 }
コード例 #4
0
ファイル: Cache.php プロジェクト: neronen/tsoha-k11p4-atomik
 /**
  * Plugin starts
  *
  * @param array $config
  */
 public static function start($config)
 {
     /* config */
     self::$config = array_merge(self::$config, $config);
 }