<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] > [官網手冊](http://php.net/manual/zh/memcache.add.php) ## 安裝 ### linux ``` yum install memcached -y ``` ### window [winx64](http://static.runoob.com/download/memcached-1.4.5-x86.zip) ## 使用 ### 參數 ``` -d是啟動一個守護進程; -m是分配給Memcache使用的內存數量,單位是MB; -u是運行Memcache的用戶; -l是監聽的服務器IP地址,可以有多個地址; -p是設置Memcache監聽的端口,,最好是1024以上的端口; -c是最大運行的并發連接數,默認是1024; -P是設置保存Memcache的pid文件。 ``` ### 啟動 ``` memcached -p 11211 -m 64m -vv ``` > 這里顯示了調試信息。這樣就在前臺啟動了memcached,監聽TCP端口11211,最大內存使用量為64M。調試信息的內容大部分是關于存儲的信息。 ### 作為后臺服務程序運行 `memcached -p 11211 -m 64m -d` ## 接口 ### set (key存在可替換) 如果 key 存在,則進行更新 ``` set key flags exptime bytes [noreply] value 參數說明如下: key:鍵值 key-value 結構中的 key,用于查找緩存值。 flags:可以包括鍵值對的整型參數,客戶機使用它存儲關于鍵值對的額外信息 。 exptime:在緩存中保存鍵值對的時間長度(以秒為單位,0 表示永遠) bytes:在緩存中存儲的字節數 noreply(可選): 該參數告知服務器不需要返回數據 value:存儲的值(始終位于第二行)(可直接理解為key-value結構中的value) ``` ### add (key存在不可替換) 當 key 存在時,不進行更新,并返回 NOT_STORED ``` add key flags exptime bytes [noreply] value ``` ### replace (key不存在會報錯) 如果 key 不存在,則替換失敗,并且您將獲得響應 NOT_STORED,可針對 `add` 替換value ``` replace key flags exptime bytes [noreply] value ``` ### append (向value后追加內容) ``` append key flags exptime bytes [noreply] value ``` eg: ``` set runoob 0 900 9 memcached STORED append runoob 0 900 5 redis get runoob VALUE runoob 0 14 memcachedredis END ``` ### prepend (向value后追加內容) ``` prepend key flags exptime bytes [noreply] value ``` ### get 獲取一個或多個value ``` get key get key key1 key2 ``` ### delete ``` delete key [noreply] ``` ### incr / decr 自增/自減 incr 與 decr 命令操作的數據必須是十進制的32位無符號整數。 ``` incr key increment_value 參數說明如下: key:鍵值 key-value 結構中的 key,用于查找緩存值。 increment_value: 增加的數值。 ``` ## demo ``` $memcache = new Memcache; //創建一個memcache對象 $memcache->connect('localhost', 11211) or die ("Could not connect"); //連接Memcached服務器 $memcache->set('key', 'key'); //設置一個變量到內存中,名稱是key 值是test $memcache->set('key1', 'key1'); //設置一個變量到內存中,名稱是key 值是test $memcache->get('key1'); //從內存中取出key的值 $memcache->delete('key1'); //刪除 $memcache->get('key1'); //bool值 false $memcache->add('key10', 'value'); $memcache->add('key10', 'value1'); $memcache->get('key10');//value add 不會進行覆蓋 $memcache->set('name', array('cpj','age'=>17,'233')); $memcache->get('name'); //可輸出數組 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看