Linux and Windows XCache installation tutorial

Source: Internet
Author: User
Tags garbage collection hash md5 php code php script time interval

XCache is another opcode cache tool that is used in PHP. Like APC, xcache stores opcode in shared memory and uses cached opcode to respond to requests for PHP footsteps.

Installing XCache on a Windows system

1, in Http://xcache.lighttpd.net/pub/ReleaseArchive according to your PHP version, download the corresponding software package.
2, after decompression to copy the Php_xcache.dll to the EXT directory

Installing XCache on the LIUNX system

The code is as follows Copy Code

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

Open the php.ini file and add the following code:

[Xcache-common]
;; Installed into Zend Extension (recommended), the path is generally "$extension _dir/xcache.so"
;; Zend_extension =/usr/local/lib/php/extensions/non-debug-non-zts-xxx/xcache.so
;; Windows System Example:
;; Zend_extension_ts = D:/php/ext/php_xcache.dll
;; Or you can install XCache into extension, make sure your extension_dir is set up correctly and place xcache.so or Php_xcache.dll in the directory.
; Extension = xcache.so
;; or WIN32 system: (Note: Because I have set the Extension_dir, so the following settings are correct, if not configured Extension_dir, need to use ZEND_EXTENSION_TS)
Extension = Php_xcache.dll

[Xcache.admin]
Xcache.admin.auth = On
Xcache.admin.user = "MOo"
; Xcache.admin.pass = MD5 ($your _password)
Xcache.admin.pass = ""

[XCache]
; Most of the options here can only be modified in INI, and here are the default values, unless otherwise stated
; Select Low Level shm/allocator scheme implemenation
Xcache.shm_scheme = "Mmap"
; Disabling: xcache.size=0
; Enable: xcache.size=64m (any >0 value) Please also note that your system mmap upper limit
Xcache.size = 64M
; Recommended set to CPU number (Cat/proc/cpuinfo |GREP-C processor)
Xcache.count = 1
; is only a reference value, you can safely store more than this number of items (PHP script/variable)
Xcache.slots = 8K
; The TTL for the cached item, 0 = Permanent
Xcache.ttl = 0
; Time interval for scanning expired items, 0 = Not scanned, other values in seconds
Xcache.gc_interval = 0
; Ditto, just for variable caching settings
Xcache.var_size = 32M
Xcache.var_count = 1
Xcache.var_slots = 8K
; Default, allow Ini_set ()
Xcache.var_ttl = 0
; Maximum TTL value
Xcache.var_maxttl = 0
Xcache.var_gc_interval = 0
; Test only with
Xcache.test = Off
; Invalid when/dev/zero
Xcache.readonly_protection = Off
; For *nix systems, the Xcache.mmap_path is a file path rather than a directory (it can not exist but must be created).
; If you expect to enable readonlyprotection, you can use a similar "/tmp/xcache"
; 2 php groups do not share the same/tmp/xcache
; For the WIN32 system, the xcache.mmap_path= anonymous map name, not the file path. Suggest using XCache Word to avoid conflict with other software
Xcache.mmap_path = "Zero"
; For *nix Systems only
; Set to null (disabled) or similar to "/tmp/phpcore/"
; Note that the directory should be able to write files to PHP (unrelated to Open_basedir)
Xcache.coredump_directory = ""
; The following project opens to implement the PHP code cache
Xcache.cacher = Off
Xcache.stat = Off
Xcache.optimizer = Off
[Xcache.coverager]
; This setting is automatically off if xcache.coveragedump_directory is set to null
Xcache.coverager = Off
; Please make sure this catalog is readable by the Coverage Viewer script (note open_basedir)
; Depend on the Xcache.coverager=on
Xcache.coveragedump_directory = ""

XCache settings
Xcache.admin.user (String) manages the authenticated user name. Default setting "MOo"
Xcache.admin.pass (String) manages the authentication password. The default setting is "<empty string>". This value should be MD5 (your password)
Xcache.admin.enable_auth (String) enables or disables authentication for the administrative site. Default value ' on '
Xcache.test (String) Enable or disable test functionality
Xcache.coredump_dir (String) The directory where the core dump is placed when a failure is encountered. Must be a writable directory for PHP. Reserved for empty strip table disabled
Xcache.cacher (Boolean) enables or disables the opcode cache. Open by default
Xcache.size (int) The size of all shared caches. If 0, the cache will not be available
Xcache.count (int) cache the number of fragmented "blocks". Default value 1
Xcache.slots Hash table hints. The larger the number, the faster the search will be in the hash table. The higher the value, the more memory is required
xcache.ttl (int) opcode The time the file is to live. 0= Unlimited Cache
Xcache.gc_interval (sec) The time interval that triggers the garbage collection. Default 0
xcache.var_size (int) Variable size
Xcache.var_count (int) variable number
Xcache.var_slots variable data slot settings
Xcache.var_ttl (SEC) variable data life time, default setting 0
Xcache.var_maxttl (SEC) maximum lifetime to process variables
Xcache.var_gc_interval (sec) lifetime of garbage collection
Xcache.readonly_protection (Boolean) is available when Readonlyprotection is enabled.
Xcache.mmap_path (String) a file path for read-only protection. This will limit two PHP groups from sharing the same/tmp/cache directory
Xcache.optimizer (Boolean) Enable or disable optimization default disable
Xcache.coverager (Boolean) enables the range of coverage data collection.
Xcache.coveragerdump_directory (String) The directory location where data collection information is placed. Default Use directory/tmp/pcovis

Instance

The code is as follows Copy Code

Class cachehelper{
    public $prefix;
    function __construct () {
       if!function_exists (' Xcache_get ') {
          exit ("This application must required XCache module. ");
      }
   }
    Public Function __set ($name, $value) {
       Xcache_set ($ This->prefix. $name, $value);
   }
 
    public Function __get ($name) {
       return Xcache_get ($this->prefix. $name);
   }
 }

Related Article

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.