瀏覽量:67次
分布式緩存管理-Memcache 是ACE為開發(fā)者提供的分布式緩存服務(wù),用來以共享的方式緩存用戶的key-value形式的小數(shù)據(jù),以加快數(shù)據(jù)響應,減輕后端存儲的壓力。
分布式緩存管理-memcache模塊主要提供以下功能:
1、 初始化memcache連接
2、 獲取memcache數(shù)據(jù)
3、寫入memcache數(shù)據(jù)
4、刷新memcache數(shù)據(jù)
使用指南實用接口:
bool Memcache::init () array Memcache::get ( array $keys [, array &$flags ] ) bool Memcache::set ( string $key , mixed $var [, int $flag [, int $expire ]] ) bool add ( string $key , mixed $var [, int $flag [, int $expire ]] ) bool replace ( string $key , mixed $var [, int $flag [, int $expire ]] ) bool decrement ( string $key [, int $value = 1 ] ) bool increment ( string $key [, int $value = 1 ] ) bool delete ( string $key [, int $timeout = 0 ] ) bool close ()
空接口:bool addServer* *( string $host [, int $port = 11211 [, bool $persistent [, int $weight [, int $timeout [, int $retry_interval [, bool$status [, callback $failure_callback [, int $timeoutms ]]]]]]]] ) bool connect* *( string $host [, int $port [, int $timeout ]] ) bool flush* *( void ) bool* *pconnect ( string $host [, int $port [, int $timeout ]] ) bool setServerParams* *( string $host [, int $port = 11211 [, int $timeout [, int $retry_interval = false [, bool $status [, callback$failure_callback ]]]]] )
用例$mem = new Memcache; $mem->init(); $mem->set('key6', 'hello', 0, 120); $val = $mem->get('key6'); echo "Get key6 value:".$val." "; $mem->add('key7', 'welcome you', 0, 120); $val = $mem->get('key7'); echo "Get add key7 value:".$var." "; $mem->set('key7', 'welcome', 0, 120); $val = $mem->get('key7'); echo "Get key7 value:".$val." "; $mem->set('key8', 'thanks', 0, 120); $val = $mem->get('key8'); echo "Get key8 value:".$val." "; $mem->replace('key8', 'thank you', false, 120); $val = $mem->get('key8'); echo "Get replace key8 value:".$val." "; $mem->delete('key6'); $val = $mem->get('key6'); echo "Get key6 value after delete:".$val." "; $mem->close(); ?>
[聲明]本網(wǎng)轉(zhuǎn)載網(wǎng)絡(luò)媒體稿件是為了傳播更多的信息,此類稿件不代表本網(wǎng)觀點,本網(wǎng)不承擔此類稿件侵權(quán)行為的連帶責任。故此,如果您發(fā)現(xiàn)本網(wǎng)站的內(nèi)容侵犯了您的版權(quán),請您的相關(guān)內(nèi)容發(fā)至此郵箱【779898168@qq.com】,我們在確認后,會立即刪除,保證您的版權(quán)。
官網(wǎng)優(yōu)化
整站優(yōu)化
渠道代理
400-655-5776