• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python umemcache.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中umemcache.Client的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testStats

    def testStats(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        d = c.stats()

        self.assertTrue (d.has_key("uptime"))
        self.assertTrue (d.has_key("bytes"))
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例2: testVersion

    def testVersion(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        v = c.version()
        l = v.split('.');

        self.assertEquals(3, len(l))
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例3: testTupleRefCrashFix

 def testTupleRefCrashFix(self):
     client = Client(MEMCACHED_ADDRESS)
     for i in range(1000):
         try:
             client.connect()
         except:
             pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例4: testCas

 def testCas(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     value, flags, cas = c.gets("key1")
     self.assertEquals("STORED", c.cas("key1", "b", cas))
     c.set("key1", "a")
     self.assertEquals("EXISTS", c.cas("key1", "b", cas))
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py


示例5: _create_connector

    def _create_connector(self):
        if self.max_item_size is not None:
            self._client = OriginalClient(self.address, self.max_item_size)
        else:
            self._client = OriginalClient(self.address)

        self.funcs = [func for func in dir(self._client)
                      if not func.startswith('_')]
开发者ID:wrongwaycn,项目名称:django-memcached-pool,代码行数:8,代码来源:client.py


示例6: testOversizedKey

 def testOversizedKey(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     data = "A" * (1000 * 1000 * 2)
     try:
         r = c.set("test", data)
         assert False
     except(RuntimeError):
         pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py


示例7: testConnectFails

    def testConnectFails(self):
        c = Client("130.244.1.1:31337");
        try:
            c.connect();
            assert False
        except:
            pass

        c.disconnect();
        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py


示例8: testConnectDNSFails

    def testConnectDNSFails(self):
        c = Client("flensost:12111");
        try:
            c.connect();
            assert False
        except:
            pass

        c.disconnect();
        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:10,代码来源:tests.py


示例9: testFlushAll

 def testFlushAll(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "31337")
     self.assertEquals(c.get("key1")[0], "31337")
     c.flush_all()
     self.assertEquals(c.get("key1"), None)
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例10: testConnectFails

    def testConnectFails(self):
        c = Client("130.244.1.1:31337");
        c.sock.settimeout(2)
        try:
            c.connect();
            assert False
        except:
            pass

        c.disconnect();
        pass
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:11,代码来源:tests.py


示例11: testPipelineDoesNotAllowReads

    def testPipelineDoesNotAllowReads(self):
        c = Client(MEMCACHED_ADDRESS)
        c.connect()

        c.begin_pipeline()

        self.assertRaises(MemcachedError, c.get, "foo")
        self.assertRaises(MemcachedError, c.gets, "foo")
        self.assertRaises(MemcachedError, c.get_multi, ["foo"])
        self.assertRaises(MemcachedError, c.gets_multi, ["foo"])
        self.assertRaises(MemcachedError, c.version)
        self.assertRaises(MemcachedError, c.stats)
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:12,代码来源:tests.py


示例12: Client

class Client(object):
    """On connection errors, tries to reconnect
    """
    def __init__(self, address, max_item_size=None, max_connect_retries=5,
                 reconnect_delay=.5):
        self.address = address
        self.max_item_size = max_item_size
        self._client = None
        self.funcs = []
        self._create_client()
        self.max_connect_retries = max_connect_retries
        self.reconnect_delay = reconnect_delay

    def _create_connector(self):
        if self.max_item_size is not None:
            self._client = OriginalClient(self.address, self.max_item_size)
        else:
            self._client = OriginalClient(self.address)

        self.funcs = [func for func in dir(self._client)
                      if not func.startswith('_')]

    def _create_client(self):
        reconnect = self._client is not None

        if reconnect:
            try:
                self._client.close()
            except Exception:
                pass

        self._create_connector()

        if reconnect:
            retries = 0
            delay = self.reconnect_delay
            while retries < self.max_connect_retries:
                try:
                    self._client.connect()
                except socket.error, exc:
                    if exc.errno == EISCONN:
                        return   # we're good
                    if exc.errno == EINVAL:
                        # we're doomed, retry
                        self._create_connector()

                    time.sleep(delay)
                    retries += 1
                    delay *= 2      # growing the delay

            raise exc
开发者ID:wrongwaycn,项目名称:django-memcached-pool,代码行数:51,代码来源:client.py


示例13: testDel

 def testDel(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     c.delete("key1")
     self.assertEquals(None, c.get("key1"))
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例14: testGets

 def testGets(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key", "value")
     self.assertEquals("value", c.gets("key")[0])
     self.assertEquals(None, c.gets("key23123"))
     r = c.gets("key")
     self.assertEquals(3, len(r))
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py


示例15: testAppend

 def testAppend(self):
     c = Client(MEMCACHED_ADDRESS)
     c.connect()
     c.set("key1", "a")
     self.assertEquals("STORED", c.append("key1", "b"))
     self.assertEquals("ab", c.get("key1")[0])
     pass
开发者ID:rfk,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例16: testPrepend

 def testPrepend(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "a")
     self.assertEquals("STORED", c.prepend("key1", "b"))
     self.assertEquals("ba", c.get("key1")[0])
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:7,代码来源:tests.py


示例17: testConnectTwice

    def testConnectTwice(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        c.disconnect();
        self.assertEquals(False, c.is_connected());

        try:
            c.connect();
            assert False
        except (RuntimeError):
            pass

        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:13,代码来源:tests.py


示例18: testGet_multi

    def testGet_multi(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        c.set("key1", "value1")
        c.set("key2", "value2")
        c.set("key3", "value3")
        r = c.get_multi(["key1", "key2", "key3", "key4"])

        self.assertEquals(("value1", 0), r["key1"])
        self.assertEquals(("value2", 0), r["key2"])
        self.assertEquals(("value3", 0), r["key3"])
        self.assertEquals(None, r.get("key4"))

        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:14,代码来源:tests.py


示例19: testReplace

    def testReplace(self):
        c = Client(MEMCACHED_ADDRESS);
        c.connect();
        c.set("key1", "value1")
        self.assertEquals("STORED", c.replace("key1", "value"))
        pass

        pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py


示例20: testBigDataFail

    def testBigDataFail(self):
    	c = Client(MEMCACHED_ADDRESS);
        c.connect();
        data = "31337" * 10000

        for x in xrange(0, 10):
            v = c.get("kaka" + str(x))
            c.set("fsdafbdsakjfjdkfjadklsafdsafdsaffdsafdasfdsafdasfsdafdsafdsafasdas" + str(x), data, 604830, 17, True)
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py



注:本文中的umemcache.Client类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python I18N._函数代码示例发布时间:2022-05-27
下一篇:
Python cli.mangle_args_for_default_framework函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap