PHP accelerator eAccelerator configuration User Guide

Source: Internet
Author: User
Tags vbulletin
PHP accelerator eAccelerator configuration User Guide

  1. # Tar-zxvf./eaccelerator-0.9.5-beta2.tar.bz2
  2. # Cd eaccelerator-0.9.5-beta2
  3. # Export PHP_PREFIX = "/usr/local" (import the PHP installation directory to the environment variable. the default value of FreeBSD is/usr/local)
  4. # $ PHP_PREFIX/bin/phpize
  5. #./Configure -- enable-eaccelerator = shared -- with-php-config = $ PHP_PREFIX/bin/php-config
  6. # Make
  7. # Make install

4. after The INI file is configured and installed, configure the php. ini file. the eAccelerator provides two configuration and call methods. Install in Zend extension mode:

  1. # Mkdir/tmp/eaccelerator
  2. # Chmod 777/tmp/eaccelerator

5. verify the installation result and access your phpinfo () page through a browser or run php-I to get the php configuration information. if the following information is displayed, the installation is successful. This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator Zend Optimizer3.0.1 is also installed on my machine, so the following information is displayed: This program makes use of the Zend Scripting Language Engine: Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies with Zend Optimizer v3.0.1, Copyright (c) 1998-2006, by Zend Technologies if you enable the debug option of eAccelerator, you can see information similar to the following in the log:

  1. Eaccelerator_lock ("count ");
  2. Eaccelerator_put ("count", eaccelerator_get ("count") + 1 ));
  3. ?>

Eaccelerator_unlock ($ key) releases a lock based on $ key

Eaccelerator_cache_output ($ key, $ eval_code, $ ttl = 0) caches $ eval_code output $ ttl seconds. (the $ ttl parameter is the same as eacclerator_put parameter.) example:

Eaccelerator_cache_result ($ key, $ eval_code, $ ttl = 0) caches $ ttl seconds for the execution result of $ eval_code code (the $ ttl parameter is the same as eacclerator_put parameter). For example:

Eaccelerator_cache_page ($ key, $ ttl = 0) caches the entire page for $ ttl seconds. For example:

  1. Eaccelerator_cache_page ($ _ SERVER ['php _ SELF '].'? GET = '. serialize ($ _ GET), 30 );
  2. Echo time ();
  3. Phpinfo ();
  4. ?>

Eaccelerator_rm_page ($ key) deletes the cache executed by eaccelerator_cache_page (). the parameter is also $ key.

2. the powerful power of eAccelerator in php code accelerated by using eAccelerator: (The code may not work in cli mode)

  1. Class test_cache {

  2. Var $ pro = 'hello ';

  3. Function test_cache (){

  4. Echo "Object Created!
    \ N ";
  5. }
  6. Function func (){
  7. Echo ', the world! ';
  8. }
  9. Function now ($ t ){
  10. Echo date ('Y-m-d H: I: S', $ t );
  11. }
  12. }

  13. $ Tt = eaccelerator_get ("test_tt ");

  14. If (! $ Tt)
  15. {
  16. $ Tt = new test_cache;
  17. Eaccelerator_put ("test_tt", $ tt );
  18. Echo "no cached!
    \ N ";
  19. }
  20. Else {
  21. Echo "cached
    \ N ";
  22. }

  23. Echo $ tt-> pro;

  24. $ Tt-> func ();
  25. $ Tt-> now (time () + 86400 );
  26. ?>

In addition, it is said that eAccelerator support has been integrated in the famous vBulletin 3.60Beta version. A piece of code from vBulletin

  1. //##############

  2. // EAccelerator

  3. /**

  4. * Class for fetching and initializing the vBulletin datastore from eAccelerator
  5. *
  6. * @ Package vBulletin
  7. * @ Version $ Revision: 0.1 $
  8. * @ Date $ Date: 2005/06/12 13:14:18 $
  9. */
  10. Class vB_Datastore_eAccelerator extends vB_Datastore
  11. {
  12. /**
  13. * Fetches the contents of the datastore from eAccelerator
  14. *
  15. * @ Param array Array of items to fetch from the datastore
  16. *
  17. * @ Return void
  18. */
  19. Function fetch ($ itemarray)
  20. {
  21. If (! Function_exists ('eaccelerator _ get '))
  22. {
  23. Trigger_error ("eAccelerator not installed", E_USER_ERROR );
  24. }

  25. Foreach ($ this-> defaultitems AS $ item)

  26. {
  27. $ This-> do_fetch ($ item );
  28. }

  29. If (is_array ($ itemarray ))

  30. {
  31. Foreach ($ itemarray AS $ item)
  32. {
  33. $ This-> do_fetch ($ item );
  34. }
  35. }

  36. $ This-> check_options ();

  37. // Set the version number variable

  38. $ This-> registry-> versionnumber = & $ this-> registry-> options ['templateversion'];
  39. }

  40. /**

  41. * Fetches the data from shared memory and detects errors
  42. *
  43. * @ Param string title of the datastore item
  44. *
  45. * @ Return void
  46. */
  47. Function do_fetch ($ title)
  48. {
  49. $ Data = eaccelerator_get ($ title );
  50. If ($ data = null)
  51. {// Appears its not there, lets grab the data, lock the shared memory and put it in
  52. $ Data = '';
  53. $ Dataitem = $ this-> dbobject-> query_first ("
  54. SELECT title, data FROM ". TABLE_PREFIX." datastore
  55. WHERE title = '". $ this-> dbobject-> escape_string ($ title )."'
  56. ");
  57. If (! Empty ($ dataitem ['title'])
  58. {
  59. $ Data = & $ dataitem ['data'];
  60. $ This-> build ($ dataitem ['title'], $ dataitem ['data']);
  61. }
  62. }
  63. $ This-> register ($ title, $ data );
  64. }
  65. /**
  66. * Updates the appropriate cache file
  67. *
  68. * @ Param string title of the datastore item
  69. *
  70. * @ Return void
  71. */
  72. Function build ($ title, $ data)
  73. {
  74. If (! Function_exists ('eaccelerator _ put '))
  75. {
  76. Trigger_error ("eAccelerator not installed", E_USER_ERROR );
  77. }
  78. Eaccelerator_lock ($ title );
  79. Eaccelerator_put ($ title, $ data );
  80. Eaccelerator_unlock ($ title );
  81. }
  82. }

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.