Install APC under MAC and use

Source: Internet
Author: User
Tags apc

1. Download the corresponding PHP version to the website APC Compression pack http://git.php.net/?p=pecl/caching/apc.git;a=commit;h= 08e2ce7ab5f59aea483d877e2bc19bb1a5bcc34f

2. Unzip and enter the APC folder

3. Perform phpize, make, sudo make install command

4. If it is in the MAMP environment, apc.so in the Extended PHP extension folder. For example, my/applications/mamp/bin/php/php5.5.26/lib/php/extensions/no-debug-non-zts-20121212 in this.

5. Open PHP.ini, add at the end

[APC]
Extension = apc.so

6. Restart Apache or Nginx

7. Open Phpinfo () command+f to search for APC, there is a successful installation

= = = Usage = = =

One, Apc_store ($key, $value, $time) and Apc_add ($key, $value, $time) methods are similar, parameters such as session, $key is a key value, $value is a value, (like an array), $time the cache time , the default is permanent.

Second, Apc_fetch ($key) gets the cache with the key value of $key

Third, Apc_delete ($key) Clear Cache

I encapsulated it as a class, as an example


Class apc{/** * APC Cache-Set Cache * Set Cache Key,value and Cache time * @param string $key key value * @param string $value value * @param string $time Cache time *///Script Academy http://www.jbxue.com Public Function Set_cache ($key, $value, $time = 0) {if ($time = = 0) $time = null;//null permanently caches return Apc_store ($key, $value, $time);; }/** * APC Cache-Get Cache * Get cached data via key * @param string $key key value */Public Function Get_cache ($key) { Return Apc_fetch ($key); /** * APC Cache-Clears a cache * Deletes a cache from Memcache * @param string $key key value */Public Function clear ($key) {return apc_delete ($key); }/** * APC Cache-Empty all caches * This feature is not recommended * @return */Public Function Clear_all () {Apc_clear_cache (' u Ser '); Clear User Cache return Apc_clear_cache (); Clear Cache}/** * Check if APC cache exists * @param string $key key value */Public function exists ($key) {Retu RN apc_exists ($key); }/** * Field self-increment-withIn the Count * @param string $key key value * @param int $step The new step value */Public Function Inc ($key, $step) { Return Apc_inc ($key, (int) $step); }/** * Field decrement-Used to count * @param string $key key value * @param int $step New Step value */Public function Dec ($ Key, $step) {return Apc_dec ($key, (int) $step); }/** * Returns APC cache information */Public Function info () {return apc_cache_info (); }} $test = new Apc (); $test->set_cache (' Zhangsan ', ' Tonight at the King of Thieves '),//$test->set_cache (' Lisi ', ' see Apple press conference ', 1); echo " <br/><br/><br/><br/><br/> "; Var_dump ($test->get_cache (' Zhangsan ')); Apc_delete ( ' Zhangsan '); Var_dump ($test->get_cache (' Zhangsan '));?>

Install APC under MAC and use

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.