⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core.php

📁 一款可以和GOOGLE媲美的开源统计系统,运用AJAX.功能强大. 无色提示:按照需要PHP5.1以上和MySQL数据库支持。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category   Zend * @package    Zend_Cache * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License *//** * @package    Zend_Cache * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License */class Zend_Cache_Core {    // ------------------    // --- Properties ---    // ------------------    /**     * Backend Object     *      * @var object     */    private $_backend = null;    /**     * Available options     *      * ====> (boolean) write_control :       * - Enable / disable write control (the cache is read just after writing to detect corrupt entries)     * - Enable write control will lightly slow the cache writing but not the cache reading     * Write control can detect some corrupt cache files but maybe it's not a perfect control     *     * ====> (boolean) caching :     * - Enable / disable caching     * (can be very usefull for the debug of cached scripts)     *      * ====> (boolean) automatic_serialization :     * - Enable / disable automatic serialization     * - It can be used to save directly datas which aren't strings (but it's slower)     *      * ====> (int) automatic_cleaning_factor :     * - Disable / Tune the automatic cleaning process     * - The automatic cleaning process destroy too old (for the given life time)     *   cache files when a new cache file is written :     *     0               => no automatic cache cleaning     *     1               => systematic cache cleaning     *     x (integer) > 1 => automatic cleaning randomly 1 times on x cache write         *     * ====> (int) lifetime :     * - Cache lifetime (in seconds)     * - If null, the cache is valid forever.     *      * ====> (boolean) logging :     * - If set to true, logging is activated (but the system is slower)     *      * @var array available options     */    protected $_options = array(        'write_control'             => true,         'caching'                   => true,         'automatic_serialization'   => false,        'automatic_cleaning_factor' => 10,        'lifetime'                  => 3600,        'logging'                   => false,        'logger'                    => null    );     /**     * Array of options which have to be transfered to backend     */    protected static $_directivesList = array('lifetime', 'logging', 'logger');    /**     * Not used for the core, just a sort a hint to get a common setOption() method (for the core and for frontends)     */    protected $_specificOptions = array();    /**     * Last used cache id     *      * @var string $_lastId     */    private $_lastId = null;        /**     * backward compatibility becase of ZF-879 and ZF-1172 (it will be removed in ZF 1.1)     *     * @var array      */    protected $_backwardCompatibilityArray = array(        'lifeTime' => 'lifetime',        'writeControl' => 'write_control',        'automaticSerialization' => 'automatic_serialization',        'automaticCleaningFactor' => 'automatic_cleaning_factor',        'cachedEntity' => 'cached_entity',        'cacheByDefault' => 'cache_by_default',        'cachedMethods' => 'cached_methods',        'nonCachedMethods' => 'non_cached_methods',        'cachedFunctions' => 'cached_functions',        'nonCachedFunctions' => 'non_cached_functions',        'masterFile' => 'master_file',        'httpConditional' => 'http_conditional',        'debugHeader' => 'debug_header',        'defaultOptions' => 'default_options',        'cacheWithGetVariables' => 'cache_with_get_variables',        'cacheWithPostVariables' => 'cache_with_post_variables',        'cacheWithSessionVariables' => 'cache_with_session_variables',        'cacheWithFilesVariables' => 'cache_with_files_variables',        'cacheWithCookieVariables' => 'cache_with_cookie_variables',        'makeIdWithGetVariables' => 'make_id_with_get_variables',        'makeIdWithPostVariables' => 'make_id_with_post_variables',        'makeIdWithSessionVariables' => 'make_id_with_session_variables',        'makeIdWithFilesVariables' => 'make_id_with_files_variables',        'makeIdWithCookieVariables' => 'make_id_with_cookie_variables'    );    // ----------------------    // --- Public methods ---    // ----------------------    /**     * Constructor     *      * @param array $options associative array of options     */    public function __construct($options = array())    {        if (!is_array($options)) {            Zend_Cache::throwException('Options parameter must be an array');        }          while (list($name, $value) = each($options)) {            $this->setOption($name, $value);        }        $this->_loggerSanity();    }    /**     * Set the backend      *      * @param object $backendObject     */    public function setBackend($backendObject)    {        if (!is_object($backendObject)) {            Zend_Cache::throwException('Incorrect backend object !');        }        $this->_backend= $backendObject;        // some options (listed in $_directivesList) have to be given        // to the backend too (even if they are not "backend specific")         $directives = array();        foreach (Zend_Cache_Core::$_directivesList as $directive) {            $directives[$directive] = $this->_options[$directive];        }        $this->_backend->setDirectives($directives);    }    /**     * Public frontend to set an option     *      * There is an additional validation (relatively to the protected _setOption method)      *      * @param string $name name of the option     * @param mixed $value value of the option     */    public function setOption($name, $value)    {        if (is_string($name)) {            if (array_key_exists($name, $this->_backwardCompatibilityArray)) {                $tmp = $this->_backwardCompatibilityArray[$name];                $this->_log("$name option is deprecated, use $tmp instead (same syntax) !");                $name = $tmp;            } else {                $name = strtolower($name);            }            if (array_key_exists($name, $this->_options)) {                // This is a Core option                $this->_setOption($name, $value);                return;            }            if (array_key_exists($name, $this->_specificOptions)) {                 // This a specic option of this frontend                $this->_specificOptions[$name] = $value;                return;            }        }         Zend_Cache::throwException("Incorrect option name : $name");    }    /**     * Set an option     *      * @param string $name name of the option     * @param mixed $value value of the option     */    private function _setOption($name, $value)    {        if (!is_string($name) || !array_key_exists($name, $this->_options)) {            Zend_Cache::throwException("Incorrect option name : $name");        }        $this->_options[$name] = $value;    }    /**     * Force a new lifetime     *      * The new value is set for the core/frontend but for the backend too (directive)     *      * @param int $newLifetime new lifetime (in seconds)     */    public function setLifetime($newLifetime)    {        $this->_options['lifetime'] = $newLifetime;        $this->_backend->setDirectives(array(            'lifetime' => $newLifetime        ));    }    /**     * Test if a cache is available for the given id and (if yes) return it (false else)     *      * @param string $id cache id

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -