How to add and set php extension xcache in win7

Source: Internet
Author: User
How to add and set php extension xcache in win7
For how to add and set xcache extensions for php in win7, xcache installation and configuration tutorial, xcache. the file/variable hash reference value cached by slots can be set according to your actual situation. For more information, see. Xcache 3.2.0, it is supported by php5 full range, official website: http://xcache.lighttpd.net/

If you are not good at English, you can switch the language to Chinese on the right.

First download the latest version: http://xcache.lighttpd.net/pub/releases/3.2.0/ remember to select the correct version.

Download and unzip the package to the ext directory under php, and then open php. ini to add extension = php_xcache.dll.

The compressed package also contains a php. ini demonstration of the Chinese version xcache, and a program for viewing xcache and information.

Note that xcache. admin. pass is stored after md5 encryption.

Xcache. count can be set based on the number of your cpu. the default value is 1.

The file/variable hash reference value cached by xcache. slots. you can set it based on your actual situation.

Restart the apache service.

; This file is just an example, please go to php. [xcache-common]; for non-windows: 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); use the password under $ your_password to encrypt it with md5 and enter it in xcache. admin. pass = "" [xcache]; most of the options here can be modified only in ini. all options listed here are default values unless otherwise stated. select the underlying memory sharing implementation scheme xcache. shm_scheme = "mmap"; disabled: xcache. size = 0; Enabled: xcache. size = 64 m and so on (any value> 0), please note that your system mmap upper limit xcache. size = 60 m. We recommend that you set it to the number of CPUs (cat/proc/cpuinfo | grep-c processor) xcache. count = 1; it is just a hash reference value. The actual storage project (php script/variable) can exceed this number xcache. slots = 8 k; cache item ttl, 0 = permanent xcache. ttl = 0; interval between scanned expired items; 0 = no scan; other values are measured in seconds. gc_interval = 0; same as above, but set xcache for variable cache. var_size = 4 m xcache. var_count = 1 xcache. var_slots = 8 k; default value of xcache _ * () function ttl parameter xcache. var_ttl = 0; the xcache _ * () function ttl parameter cannot exceed this setting. 0 = no xcache restrictions. var_maxttl = 0 xcache. var_gc_interval = 300;/dev/zero is invalid xcache. readonly_protection = off; for * nix systems, xcache. mmap_path is the file path rather than the directory. (Automatic creation/overwriting); if you want to enable readonlyprotection, you must avoid using "/dev/*", you can use "/tmp/xcache "; different php process groups do not share the same/tmp/xcache. for win32 systems, xcache. mmap_path = Anonymous map name, not the file path. we recommend that you use xcache to avoid conflicts with other software. mmap_path = "/dev/zero"; used only when xcache is abnormal. set it to null (disabled) or similar to "/tmp/phpcore/" (files can be written by php) xcache. coredump_directory = ""; only for windows. keep the default value xcache unless the xcache developer tells you. coredump_type = 0; cache xcache is disabled automatically when an exception occurs. disable_on_crash = off; enable the experiment function (if any) xcache. experimental = off; the following are request-level changes. ini_set ,. htaccess and other xcache. cacher = on xcache. stat = on xcache. optimizer = off [xcache. coverager]; this function reduces the running performance only after it is enabled. coverager = on & xcache. this function is enabled only when coveragedump_directory = "non-null"; per request settings. ini_set ,. enables code flow coverage information collection and xcache_coverager_start/stop/get/clean () functions such as xcache. coverager = off xcache. coverager_autostart = on; set only in the php ini file; make sure that the directory can be read by the coverage viewer script (note open_basedir) xcache. coveragedump_directory = ""

Check phpinfo to see if xcache has taken effect. For example

Now, create a new directory such as xcache in the web release directory and put the lib and htdocs directories in the official compressed package,

Enter http: // 127.0.0.1/xcache/htdocs/in the browser, and a login account and password dialog box will pop up. after entering this box, you will see the xcache environment and configuration, variable ..

But in fact, xcache not only caches variables, but also caches php files. if xcache extension is configured in your php environment, it automatically caches all the php files you access each time. No additional code modification is required, which is very convenient and quick. for example, if I only access phpmyadmin, the official xcache package can detect the phpmyadmin cache list.

The code is very simple, with the singleton mode, which can be used directly in the application environment. the code passes the perfect test in php5.5.12.

$ C = new cache_xcache (); $ c-> set ('key', 'aaaa123 '); echo $ c-> get ('key'); cache_xcache :: getinstance ()-> set ('key1', '20140901'); echo cache_xcache: getinstance ()-> get ('key1 '); /** -------------------------------- code start ---------------------------------- **/class cache_xcache {/*** single instance mode instantiates this class ** @ var object */protected static $ _ instance = null; /*** default cache policy ** @ var array */protected $ _ defaultopt Ions = array ('expire '=> 900);/*** constructor ** @ access public * @ return boolean */public function _ construct () {// analyze the 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 mixted $ value cache value * @ param integer $ expire lifecycle ** @ 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 cache, false ** @ access public ** @ param string $ key cache key ** @ return mixted */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 ** is used in singleton mode of this class) instantiate ** @ access public * @ return object */public static function getinstance () {if (! Self ::$ _ instance) {self ::$ _ instance = new self ();} return self ::$ _ instance ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.