This time I will bring you an analysis of the installation and use cases of the PHP caching tool XCache. What are the precautions for the installation and use of the PHP caching tool
XCache is another Opcode caching tool used in PHP. Like APC, XCache stores opcodes in shared memory and uses the cached opcodes to respond to requests for PHP scripts.
Install XCache on Windows system
1. At http://xcache.lighttpd.net/pub/ReleaseArchive according to your PHP version, download the corresponding software package.
2. After decompression, copy php_xcache.dll to the ext directory
3. Add
[XCache] Zend_extension_ts=php_xcache.dall
to the PHP.ini file on the Liunx system Install XCache
wget http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz tar -zxvf xcache-1.3.2.tar.gz cd xcache-1.3.2 phpize ./configure --enable-xcache make make install doc.codesky.net
Open the php.ini file and add the following code:
[xcache-common] ; change me - 64 bit php => /usr/lib64/php/modules/xcache.so ; 32 bit php => /usr/lib/php/modules/xcache.so zend_extension = /usr/lib64/php/modules/xcache.so [xcache.admin] xcache.admin.auth = On xcache.admin.user = "mOo" ; xcache.admin.pass = md5($your_password) xcache.admin.pass = "" [xcache] xcache.shm_scheme = "mmap" xcache.size = 32M xcache.count = 1 xcache.slots = 8K xcache.ttl = 3600 xcache.gc_interval = 300 ; Same as aboves but for variable cache ; If you don't know for sure that you need this, you probably don't xcache.var_size = 0M xcache.var_count = 1 xcache.var_slots = 8K xcache.var_ttl = 0 xcache.var_maxttl = 0 xcache.var_gc_interval = 300 ; N/A for /dev/zero xcache.readonly_protection = Off xcache.mmap_path = "/dev/zero" xcache.cacher = On xcache.stat = On
Note the modificationzend_extension = /usr/lib64/php/modules/xcache. so is the correct path.
XCache settings
xcache.admin.user (String) Management authentication user name. The default setting is "mOo"
xcache.admin.pass (String) management authentication password. The default setting is "
xcache.admin.enable_auth (String) Enables or disables authentication for the admin site. The default value is "on"
xcache.test (String) Enable or disable the test function
xcache.coredump_dir (String) The directory where the core dump is placed when a failure is encountered. Must be a directory writable by PHP. Leave empty with table disabled
xcache.cacher (Boolean) Enable or disable Opcode cache. Enabled by default
xcache.size (int) The size of all shared caches. If 0, the cache will not be able to use
xcache.count (int) The number of "chunks" the cache is divided into. Default value 1
xcache.slots Hash table hint. The larger the number, the faster the search occurs within the hash table. The higher this value is, the more memory is required
xcache.ttl (int) The survival time of the Opcode file. 0=Indefinite cache
xcache.gc_interval (seconds) The time interval for triggering garbage collection. Default 0
xcache.var_size (int) Variable size
xcache.var_count (int) Number of variables
xcache.var_slots Variable data slot settings
xcache.var_ttl (seconds) Survival of variable data Time, default setting 0
xcache.var_maxttl (seconds) Maximum survival time when processing variables
xcache.var_gc_interval (seconds) Lifetime of garbage collection
xcache.readonly_protection (Boolean) Available when ReadonlyProtection is enabled.
xcache.mmap_path (String) File path for read-only protection. This will restrict two PHP groups from sharing the same /tmp/cache directory
xcache.optimizer (Boolean) Enable or disable optimization Disabled by default
xcache.coverager (Boolean) Enable coverage Dataset combine.
xcache.coveragerdump_directory (String) The directory location where the data collection information is placed. The default directory /tmp/pcovis
Instance
reference www.initphp.com framework Xcache class
<?php if (!defined('IS_INITPHP')) exit('Access Denied!'); /********************************************************************************* * InitPHP 2.0 国产PHP开发框架 Dao-XCACHE缓存 *------------------------------------------------------------------------------- * 版权所有: CopyRight By initphp.com * 您可以自由使用该源码,但是在使用过程中,请保留作者信息。尊重他人劳动成果就是尊重自己 *------------------------------------------------------------------------------- * $Author:zhuli * $Dtime:2011-10-09 ***********************************************************************************/ class xcacheInit { /** * Xcache缓存-设置缓存 * 设置缓存key,value和缓存时间 * @param string $key KEY值 * @param string $value 值 * @param string $time 缓存时间 */ public function set_cache($key, $value, $time = 0) { return xcache_set($key, $value, $time);; } /** * Xcache缓存-获取缓存 * 通过KEY获取缓存数据 * @param string $key KEY值 */ public function get_cache($key) { return xcache_get($key); } /** * Xcache缓存-清除一个缓存 * 从memcache中删除一条缓存 * @param string $key KEY值 */ public function clear($key) { return xcache_unset($key); } /** * Xcache缓存-清空所有缓存 * 不建议使用该功能 * @return */ public function clear_all() { $tmp['user'] = isset($_SERVER['PHP_AUTH_USER']) ? null : $_SERVER['PHP_AUTH_USER']; $tmp['pwd'] = isset($_SERVER['PHP_AUTH_PW']) ? null : $_SERVER['PHP_AUTH_PW']; $_SERVER['PHP_AUTH_USER'] = $this->authUser; $_SERVER['PHP_AUTH_PW'] = $this->authPwd; $max = xcache_count(XC_TYPE_VAR); for ($i = 0; $i < $max; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } $_SERVER['PHP_AUTH_USER'] = $tmp['user']; $_SERVER['PHP_AUTH_PW'] = $tmp['pwd']; return true; } /** * Xcache验证是否存在 * @param string $key KEY值 */ public function exists($key) { return xcache_isset($key); } }
believe it After reading the case in this article, you have mastered the method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Detailed explanation of PHP mongoDB database operation steps
Querying the PHP string to contain the specified data
The above is the detailed content of PHP caching tool XCache installation and use case analysis. For more information, please follow other related articles on the PHP Chinese website!

php把负数转为正整数的方法:1、使用abs()函数将负数转为正数,使用intval()函数对正数取整,转为正整数,语法“intval(abs($number))”;2、利用“~”位运算符将负数取反加一,语法“~$number + 1”。

实现方法:1、使用“sleep(延迟秒数)”语句,可延迟执行函数若干秒;2、使用“time_nanosleep(延迟秒数,延迟纳秒数)”语句,可延迟执行函数若干秒和纳秒;3、使用“time_sleep_until(time()+7)”语句。

php除以100保留两位小数的方法:1、利用“/”运算符进行除法运算,语法“数值 / 100”;2、使用“number_format(除法结果, 2)”或“sprintf("%.2f",除法结果)”语句进行四舍五入的处理值,并保留两位小数。

判断方法:1、使用“strtotime("年-月-日")”语句将给定的年月日转换为时间戳格式;2、用“date("z",时间戳)+1”语句计算指定时间戳是一年的第几天。date()返回的天数是从0开始计算的,因此真实天数需要在此基础上加1。

php判断有没有小数点的方法:1、使用“strpos(数字字符串,'.')”语法,如果返回小数点在字符串中第一次出现的位置,则有小数点;2、使用“strrpos(数字字符串,'.')”语句,如果返回小数点在字符串中最后一次出现的位置,则有。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

php字符串有下标。在PHP中,下标不仅可以应用于数组和对象,还可应用于字符串,利用字符串的下标和中括号“[]”可以访问指定索引位置的字符,并对该字符进行读写,语法“字符串名[下标值]”;字符串的下标值(索引值)只能是整数类型,起始值为0。

查找方法:1、用strpos(),语法“strpos("字符串值","查找子串")+1”;2、用stripos(),语法“strpos("字符串值","查找子串")+1”。因为字符串是从0开始计数的,因此两个函数获取的位置需要进行加1处理。


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor

Zend Studio 13.0.1
Powerful PHP integrated development environment
