PHP script Memcache class of source code

Source: Internet
Author: User
Tags php script

<?PHP/** * @example $mem = new Memcached (); * @example $getCache = $mem->get (' Test '); * @example memcache_host Host * @examp Le memcache_port Port * @example memcache_timeout Cache time*/classMemcached {Private$memcache =NULL; /** * @desc Constructors*/     Publicfunction __construct () {$ This->memcache =NewMemcache; $ This->memcache->Connect (memcache_host, Memcache_port, memcache_timeout); }           /** * Compatible with PHP4*/     Publicfunction Memcached () {$ This-__construct (); }           /** * @desc Gets the value of memcache based on key * @param string $name Key name * @return Array or string*/     PublicfunctionGet($name, $isJson =true) {$value= $ This->memcache->Get($name); if($isJson) $value= Json_decode ($value,true); return$value; }       /** * Set the cache, if it exists on the update, does not exist then add, if successful returns TRUE, Failure returns FALSE. * @param string $name Key name * @param array or array $value value value * @param boolean $ttl whether to compress * @param int $ext 1 used to set an expired auto-destroy time * @return Boolean*/     PublicfunctionSet($name, $value, $ext 1 =false, $ttl =0)    {        return$ This->memcache->Set($name, $value, $ext 1, $ttl); }       /** * Add cache, return TRUE if successful, or FALSE if unsuccessful. * @param string $name Key name * @param array or array $value value value * @param boolean $ttl whether to compress * @param int $ext 1 used to set an expired auto-destroy time * @return Boolean*/     Publicfunction Add ($name, $value, $ext 1 =false, $ttl =0)    {           return$ This->memcache->Add ($name, $value, $ext 1, $ttl); }        /** * @desc Delete the cache, returns TRUE if successful, and FALSE if it fails. * @param string $name Key Name * @return Boolean*/     Publicfunction Delete ($name) {return$ This->memcache->Delete ($name); }           /** * @desc Close a Memcache object * @return Blloean*/     Publicfunction Close () {return$ This->memcache->Close (); }       /** * @desc Increment item ' s value (addition operation) * @param string $name * @param int $value Increment the item by V Alue.     Optional and Defaults to 1. * @return Type*/     Publicfunction Increment ($name, $value) {return$ This->memcache->Increment ($name, $vlaue); }           /** * @desc Decrement item ' s value (subtraction operation) * @param string $name * @param int $value Decrement the item by V Alue.     Optional and Defaults to 1. * @return Type*/     Publicfunction Decrement ($name, $value) {return$ This->memcache->Decrement ($name, $vlaue); }           /** * @desc get run system statistics for all processes in the process pool * @return Array*/     Publicfunction Getextendedstats () {return$ This->memcache->getextendedstats (); }           /** * @desc returns some running statistics for the server * @return Array*/     Publicfunction GetStats () {return$ This->memcache->getstats (); }       /** * @desc empties the cache, returns TRUE if successful, and FALSE if it fails. * @return Boolean*/     Publicfunction Flush () {return$ This->memcache->Flush (); }}?>

PHP script memcache class source code

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.