EAcceleratorAPI development in PHP

Source: Internet
Author: User
EAcceleratorAPI development in PHP

  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. use eAccelerator to accelerate php code. In addition, the eAccelerator support has been integrated in PHPCMS. Below is a piece of code from PHPCMS.

  1. Class cache

  2. {
  3. Function _ construct ()
  4. {
  5. }

  6. Function cache ()

  7. {
  8. $ This->__ construct ();
  9. }

  10. Function get ($ name)

  11. {
  12. Return eaccelerator_get ($ name );
  13. }

  14. Function set ($ name, $ value, $ ttl = 0)

  15. {
  16. Eaccelerator_lock ($ name );
  17. Return eaccelerator_put ($ name, $ value, $ ttl );
  18. }

  19. Function rm ($ name)

  20. {
  21. Return eaccelerator_rm ($ name );
  22. }

  23. Function clear ()

  24. {
  25. Return eaccelerator_gc ();
  26. }
  27. }

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.