PHP Accelerator eaccelerator Configuration Usage Guide

Source: Internet
Author: User
Tags echo date vbulletin zend
    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 into the environment variable, freebsd default 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
Copy Code

4, INI file configuration installation is complete, the following start to configure the php.ini file, Eaccelerator provides two ways to configure and call, respectively, as follows. Install as Zend extension mode:

    1. #mkdir/tmp/eaccelerator
    2. #chmod 777/tmp/eaccelerator
Copy Code

5, verify the installation results through the browser to access your phpinfo () page or run php-i to get the PHP configuration information, if you see a message similar to the following indicates that the installation was 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 I have also installed Zend on my machine Optimizer3.0.1, so see the following information: This program makes use of the Zend Scripting Language engine:zend Engine v2.1.0, Copyright (c) 19 98-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-20 , by Zend Technologies if you turn on the debug option for Eaccelerator, you can see information like the following from the log

    1. Eaccelerator_lock ("Count");
    2. Eaccelerator_put ("Count", Eaccelerator_get ("Count") +1));
    3. ?>
Copy Code

Eaccelerator_unlock ($key) Release lock according to $key

Eaccelerator_cache_output ($key, $eval _code, $ttl =0) will $eval the output cache of the _code code $ttl seconds, ($ttl parameters with Eacclerator_put) such as:

Copy Code

Eaccelerator_cache_result ($key, $eval _code, $ttl =0) caches the execution results of the $eval _code code $ttl seconds, ($ttl parameter is the same as Eacclerator_put), similar to cache_ Output for example:

Copy Code

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

    1. Eaccelerator_cache_page ($_server[' php_self '). Get= '. Serialize ($_get), 30);
    2. echo Time ();
    3. Phpinfo ();
    4. ?>
Copy Code

Eaccelerator_rm_page ($key) deletes the cache executed by Eaccelerator_cache_page (), and the parameters are also $key

2, PHP code using eaccelerator accelerated test eaccelerator Powerful: (This code may not be valid 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. ?>
Copy Code

In addition, it is said that the support for Eaccelerator has been integrated in the famous vbulletin 3.60Beta version. A piece of code from vbulletin inside

  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 the 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. }

Copy Code
  • 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.