In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how PHP uses eAccelerator's API development. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
1. API and documentation:
EAccelerator provides a convenient and stable native cache implementation. Because most of the code implementations are based on shared memory, they can only be used in * nix platform. Windows platform Michael does not know when it will be supported in this respect.
EAccelerator provides the following API interfaces and files: (the following files are all in the doc/php/ directory of the source package)
File list:
The copy code is as follows:
Cache.php
Dasm.php
Encoder.php
Info.php
Loader.php
Session.php
Shared_memory.php
Interface list:
The copy code is as follows:
Array eaccelerator_cached_scripts ()
Void eaccelerator_cache_output (string $key, string $eval_code, [int $ttl = 0])
Void eaccelerator_cache_page (string $key, [int $ttl = 0])
Void eaccelerator_cache_result (string $key, string $code, [int $ttl = 0])
Void eaccelerator_caching (boolean $flag)
Void eaccelerator_clean ()
Void eaccelerator_clear ()
Array eaccelerator_dasm_file (mixed $filename)
Mixed eaccelerator_encode (mixed $src, [mixed $prefix ='], [string $pre_content ='], [string $post_content ='])
Void eaccelerator_gc ()
Mixed eaccelerator_get (string $key)
Array eaccelerator_info ()
Array eaccelerator_list_keys ()
Void eaccelerator_load ()
Boolean eaccelerator_lock (string $key)
Void eaccelerator_optimizer (boolean $flag)
Void eaccelerator_purge ()
Boolean eaccelerator_put (string $key, mixed $value, [int $ttl = 0])
Array eaccelerator_removed_scripts ()
Boolean eaccelerator_rm (string $key)
Void eaccelerator_rm_page (string $key)
Boolean eaccelerator_set_session_handlers ()
Boolean eaccelerator_unlock (string $key)
Here are some of the translated APIs:
The copy code is as follows:
Eaccelerator_put ($key, $value, $ttl=0)
Store $value in the cache with the key name of $key (object types are supported in php4. It seems that the source code does not support it in zend2). $ttl is the lifetime of the cache (in seconds). Omitting this parameter or specifying 0 means unlimited time until the server is rebooted and emptied.
Eaccelerator_get ($key)
According to $key, the data stored in the corresponding eaccelerator_put () is returned from the cache. If the cache has expired or does not exist, the return value is NULL.
Eaccelerator_rm ($key)
Remove the cache according to $key
Eaccelerator_gc ()
Remove and clean up all expired key
Eaccelerator_lock ($key)
Add a lock operation to $key to ensure data synchronization during multiprocess and multithreaded operations. You need to call eaccelerator_unlock ($key) to release the lock or wait for the lock to be released automatically when the program request ends.
For example:
Eaccelerator_cache_page ($key, $ttl=0)
Caches the current full page for $ttl seconds.
For example:
Eaccelerator_rm_page ($key)
Delete the cache executed by eaccelerator_cache_page (), and the parameter is also $key
2. Use eAccelerator acceleration in PHP code
In addition, eAccelerator support has been integrated into PHPCMS. Here is a piece of code from PHPCMS.
The copy code is as follows:
Class cache
{
Function _ construct ()
{
}
Function cache ()
{
$this- > _ _ construct ()
}
Function get ($name)
{
Return eaccelerator_get ($name)
}
Function set ($name, $value, $ttl = 0)
{
Eaccelerator_lock ($name)
Return eaccelerator_put ($name, $value, $ttl)
}
Function rm ($name)
{
Return eaccelerator_rm ($name)
}
Function clear ()
{
Return eaccelerator_gc ()
}
}
This is the end of this article on "how PHP uses eAccelerator's API development". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.