


Detailed tutorial on adding and setting up php extension xcache in win7
Regarding the method of adding and setting the xcache extension for PHP in the win7 system, the installation and configuration tutorial of xcache, the file/variable hash reference value of the xcache.slots cache, you can set it according to your actual situation, and friends who need it can refer to it.
xcache 3.2.0, which is supported by the full range of php5, official website: http://xcache.lighttpd.net/
If you are not good at English, you can click on the right to switch the language to Chinese. First, download the latest version: http://xcache.lighttpd.net/pub/releases/3.2.0/ Remember to select the correct version. Download and unzip it and put it in the ext directory under php, then open php.ini and add extension = php_xcache.dll The compressed package also contains a demonstration of the Chinese version of xcache's php.ini, and a program to view xcache and information. Note that xcache.admin.pass is encrypted with md5 and stored xcache.count can be set according to the number of your cpu, the default is 1 xcache.slots cached file/variable hash reference value, you can set it according to your actual situation Once completed, restart the apache service. ;; This file is just an example, please set it in php.ini for it to take effect [xcache-common] ;; Non-windows example: extension=xcache.so ;; windows system example: ; extension = php_xcache.dll [xcache.admin] xcache.admin.enable_auth = on xcache.admin.user = "moo" ; xcache.admin.pass = md5($your password) ; Log in using $your_password. Please encrypt the password with md5 and fill it in. xcache.admin.pass = "" [xcache] ; Most of the options here can only be modified in the ini. The default values listed here are unless otherwise stated. ; Select the underlying memory sharing implementation solution xcache.shm_scheme = "mmap" ; Disabled: xcache.size=0 ; Enable: xcache.size=64m and the like (any value >0) Also please pay attention to your system mmap upper limit xcache.size = 60m ; It is recommended to set it to the number of cpu (cat /proc/cpuinfo |grep -c processor) xcache.count = 1 ; It's just a hash reference value, the actual storage items (php scripts/variables) can exceed this number xcache.slots = 8k ; ttl of cached items, 0=permanent xcache.ttl = 0 ; The time interval for scanning expired items, 0=no scanning, other values are in seconds xcache.gc_interval = 0 ; Same as above, only for variable cache settings xcache.var_size = 4m xcache.var_count = 1 xcache.var_slots = 8k ; Default value of xcache_*() function ttl parameter xcache.var_ttl = 0 ; Limit xcache_*() function ttl parameters to no more than this setting. 0=No limit xcache.var_maxttl = 0 xcache.var_gc_interval = 300 ; Invalid when /dev/zero xcache.readonly_protection = off ; For *nix systems, xcache.mmap_path is a file path rather than a directory. (Automatically created/overwritten) ; If you wish to enable readonlyprotection, you must avoid using "/dev/*" and use something like "/tmp/xcache" ; Different php process groups will not share the same /tmp/xcache ; For win32 systems, xcache.mmap_path=anonymous map name, not file path. It is recommended to use the word xcache to avoid conflicts with other software xcache.mmap_path = "/dev/zero" ; Only useful when xcache exceptions occur. Set to empty (disabled) or similar to "/tmp/phpcore/" (can be written to files by php) xcache.coredump_directory = "" ; For windows only. Unless the xcache developer tells you otherwise, keep the default value xcache.coredump_type = 0 ; Automatically disable caching when exception occurs xcache.disable_on_crash = off ; Enable experimental features (if any) xcache.experimental=off ; The following are request-level settings that can be changed. Can be ini_set, .htaccess, etc. xcache.cacher = on xcache.stat = on xcache.optimizer = off [xcache.coverager] ; This function will reduce operating performance after it is turned on. ; This feature will only be enabled when xcache.coverager == on && xcache.coveragedump_directory == "non-null value" ; per request settings. Can be ini_set, .htaccess, etc. ; Enable code process coverage information collection and functions such as xcache_coverager_start/stop/get/clean() xcache.coverager = off xcache.coverager_autostart = on ; Only set within php ini files ; Please ensure that this directory can be read by the coverage viewer script (note open_basedir) xcache.coveragedump_directory = ""
Then check phpinfo to see if xcache has taken effect. As shown below Now create a new directory such as xcache in the web publishing directory, and put the lib and htdocs directories in the official compressed package inside, Enter http://127.0.0.1/xcache/htdocs/ in the browser, and a login account and password dialog box will pop up. After entering it, you can see the xcache environment and configuration, variables, etc. . But in fact, xcache can not only cache variables, but also cache php files. If the xcache extension is configured in your php environment, it will automatically cache every php file you access. There is no need to modify the code, it is very convenient and fast. As shown in the picture below, I only accessed phpmyadmin, and the official xcache package can detect the cache list of phpmyadmin. The code is very simple, with singleton mode and can be used directly in the application environment. The code has been perfectly tested in php5.5.12. $c =new cache_xcache(); $c->set('key', 'aaaa123'); echo $c->get('key'); cache_xcache::getinstance()->set('key1', '999999999999999'); echo cache_xcache::getinstance()->get('key1'); /**----------------------------------Code starts------------------ ----------------**/ class cache_xcache { /*** Instantiate this class in singleton mode * * @var object*/ protected static $_instance = null; /***Default caching strategy * * @var array*/ protected $_defaultoptions = array('expire' => 900); /*** Construction method * * @access public * @return boolean*/ public function __construct() { //Analyze xcache extension module if (!extension_loaded('xcache')) { die('the xcache extension to be loaded before use!'); } return true; } /*** Write cache * * @access public * * @param string $key cache key * @param mixed $value cache value * @param integer $expire lifetime * * @return boolean*/ public function set($key, $value, $expire = null) { //Parameter analysis if (!$key) { return false; } $expire = is_null($expire) ? $this->_defaultoptions['expire'] : $expire; return xcache_set($key, $value, $expire); } /*** Read the cache and return false if it fails or the cache is invalid. * * @access public * * @param string $key cache key * * @return mixed*/ public function get($key) { //Parameter analysis if (!$key) { return false; } return xcache_isset($key) ? xcache_get($key) : false; } /*** Cache a variable to data storage * * @access public * * @param string $key data key * @param mixed $value data value * @param int $expire cache time (seconds) * * @return boolean*/ public function add($key, $value, $expire = null) { //Parameter analysis if (!$key) { return false; } $expire = is_null($expire) ? $this->_defaultoptions['expire'] : $expire; return !xcache_isset($key) ? $this->set($key,$value,$expire) : false; } /*** Delete the specified cache * * @access public * * @param string $key cache key * * @return boolean*/ public function delete($key) { //Parameter analysis if (!$key) { return false; } return xcache_unset($key); } /*** Clear all cache variables * * @access public * @return boolean*/ public function clear() { return xcache_clear_cache(xc_type_var, 0); } /*** Singleton mode * * Used for singleton instantiation of this class * * @access public * @return object*/ public static function getinstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; } } |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
