<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國際加速解決方案。 廣告
                ## 安裝包 * 到[中文官網](http://redis.cn/clients.html)查找客戶端代碼 * 聯網安裝 ~~~ sudo pip install redis ~~~ * 使用源碼安裝 ~~~ unzip redis-py-master.zip cd redis-py-master sudo python setup.py install ~~~ ## 交互代碼 * 引入模塊 ~~~ import redis ~~~ * 連接 ~~~ try: r=redis.StrictRedis(host='localhost',port=6379) except Exception,e: print e.message ~~~ * 方式一:根據數據類型的不同,調用相應的方法,完成讀寫 * 更多方法同前面學的命令 ~~~ r.set('name','hello') r.get('name') ~~~ * 方式二:pipline * 緩沖多條命令,然后一次性執行,減少服務器-客戶端之間TCP數據庫包,從而提高效率 ~~~ pipe = r.pipeline() pipe.set('name', 'world') pipe.get('name') pipe.execute() ~~~ ## 封裝 * 連接redis服務器部分是一致的 * 這里將string類型的讀寫進行封裝 ~~~ import redis class RedisHelper(): def __init__(self,host='localhost',port=6379): self.__redis = redis.StrictRedis(host, port) def get(self,key): if self.__redis.exists(key): return self.__redis.get(key) else: return "" def set(self,key,value): self.__redis.set(key,value) ~~~ ## python3代碼 ~~~ #!/usr/bin/env python # -*- coding: utf-8 -*- ''' @Time : 5/18/18 7:39 PM @Author : haibo @File : MyRedis.py ''' from redis import * # r = StrictRedis(host='localhost', port=6379) # write # pipe = r.pipeline() # pipe.set('py10', 'hello1') # pipe.set('py11', 'world') # pipe.execute() # read # temp = r.get('py10') # print(temp) class redisHelper(object): def __init__(self, host, port): self.__redis = StrictRedis(host, port) def set(self, key, value): self.__redis.set(key, value) def get(self, key): return self.__redis.get(key) ~~~
                  <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>

                              哎呀哎呀视频在线观看