当前位置: 首页>>代码示例>>Python>>正文


Python Client.get方法代码示例

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


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

示例1: testFlushAll

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 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,代码行数:9,代码来源:tests.py

示例2: testGet

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testGet(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key", "value")
     self.assertEquals("value", c.get("key")[0])
     self.assertEquals(None, c.get("key23123"))
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:9,代码来源:tests.py

示例3: testDel

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 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,代码行数:9,代码来源:tests.py

示例4: testPrepend

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 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,代码行数:9,代码来源:tests.py

示例5: testAppend

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 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,代码行数:9,代码来源:tests.py

示例6: testBigDataFail

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
    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,代码行数:10,代码来源:tests.py

示例7: testSockAccess

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testSockAccess(self):
     # accessing the members before connect() is called
     c = Client(MEMCACHED_ADDRESS)
     self.assertEquals(c.host, MEMCACHED_HOST)
     self.assertEquals(c.port, MEMCACHED_PORT)
     self.assertTrue(isinstance(c.sock, socket.socket))
     c.sock.settimeout(2)
     c.connect()
     c.set("key1", "31337")
     self.assertEquals(c.get("key1")[0], "31337")
开发者ID:noonat,项目名称:ultramemcache,代码行数:12,代码来源:tests.py

示例8: testRandomData

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
    def testRandomData(self):
        def random_bytes(size):
            return "".join(chr(random.randrange(0, 256)) for i in xrange(size))

        def random_str(size):
            return "".join(chr(random.randrange(33, 64)) for i in xrange(size))

        c = Client(MEMCACHED_ADDRESS)
        c.connect()

        count = 0

        for x in xrange(0, 10):
            key = random_str(random.randrange(1, 33))
            value = random_bytes(random.randrange(1, 5000))
            c.set(key, value, 0, 0, True)
            v2 = c.get(key)[0]

            count += 1

            if len(value) != len(v2):
                print "%d %d != %d" % (count, len(value), len(v2))
开发者ID:rfk,项目名称:ultramemcache,代码行数:24,代码来源:tests.py

示例9: testMaxSize

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testMaxSize(self):
     c = Client(MEMCACHED_ADDRESS, 1)
     c.connect()
     self.assertRaises(RuntimeError, c.set, 'key1', 'xx')
     c.set("key1", "3")
     self.assertEquals(c.get("key1")[0], "3")
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py

示例10: testDecr

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testDecr(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "31337")
     c.decr("key1", 31337)
     self.assertEquals(0, long(c.get("key1")[0]))
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py

示例11: testIncr

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testIncr(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key1", "0")
     c.incr("key1", 313370)
     self.assertEquals("313370", c.get("key1")[0])
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py

示例12: testSet

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
 def testSet(self):
     c = Client(MEMCACHED_ADDRESS);
     c.connect();
     c.set("key", "my new value")
     self.assertEquals("my new value", c.get("key")[0])
     pass
开发者ID:noonat,项目名称:ultramemcache,代码行数:8,代码来源:tests.py

示例13: testPipeline

# 需要导入模块: from umemcache import Client [as 别名]
# 或者: from umemcache.Client import get [as 别名]
    def testPipeline(self):
        c1 = Client(MEMCACHED_ADDRESS)
        c2 = Client(MEMCACHED_ADDRESS)
        c1.connect()
        c2.connect()

        c1.flush_all()

        # Basic Multi-Set
        c1.set("foo", "bar")
        self.assertEquals("bar", c1.get("foo")[0])
        c2.begin_pipeline()
        c2.set("foo", "bim")
        c2.set("foo2", "baz")
        self.assertEquals("bar", c1.get("foo")[0])
        res = c2.finish_pipeline()
        self.assertEquals(["STORED", "STORED"], res)
        self.assertEquals("bim", c1.get("foo")[0])
        self.assertEquals("baz", c1.get("foo2")[0])

        # Abort
        c2.begin_pipeline()
        c2.set("foo", "baz")
        c2.abort_pipeline()
        self.assertNotEqual("baz", c1.get("foo")[0])

        # Incr/Decr
        c1.set("counter", "1")
        self.assertEquals("1", c1.get("counter")[0])
        c2.begin_pipeline()
        c2.incr("counter", 10)
        c2.decr("counter", 5)
        self.assertEquals("1", c1.get("counter")[0])
        c2.finish_pipeline()
        self.assertEquals("6", c1.get("counter")[0])

        # Add
        c1.set("added1", "foo")
        c1.set("added2", "bar")
        self.assertEquals("foo", c1.get("added1")[0])
        self.assertEquals("bar", c1.get("added2")[0])
        c2.begin_pipeline()
        c2.add("added1", "bim")
        c2.add("added2", "baz")
        c2.add("added3", "oof")
        c2.add("added4", "rab")
        self.assertEquals("foo", c1.get("added1")[0])
        self.assertEquals("bar", c1.get("added2")[0])
        self.assertEquals(None, c1.get("added3"))
        self.assertEquals(None, c1.get("added4"))
        res = c2.finish_pipeline()
        self.assertEquals(["NOT_STORED", "NOT_STORED", "STORED", "STORED"], res)
        self.assertEquals("foo", c1.get("added1")[0])
        self.assertEquals("bar", c1.get("added2")[0])
        self.assertEquals("oof", c1.get("added3")[0])
        self.assertEquals("rab", c1.get("added4")[0])

        # Replace
        c1.set("replace1", "foo")
        c1.set("replace2", "bar")
        self.assertEquals("foo", c1.get("replace1")[0])
        self.assertEquals("bar", c1.get("replace2")[0])
        c2.begin_pipeline()
        c2.replace("replace1", "bim")
        c2.replace("replace2", "baz")
        c2.replace("replace3", "oof")
        c2.replace("replace4", "rab")
        self.assertEquals("foo", c1.get("replace1")[0])
        self.assertEquals("bar", c1.get("replace2")[0])
        self.assertEquals(None, c1.get("replace3"))
        self.assertEquals(None, c1.get("replace4"))
        res = c2.finish_pipeline()
        self.assertEquals(["STORED", "STORED", "NOT_STORED", "NOT_STORED"], res)
        self.assertEquals("bim", c1.get("replace1")[0])
        self.assertEquals("baz", c1.get("replace2")[0])
        self.assertEquals(None, c1.get("replace3"))
        self.assertEquals(None, c1.get("replace4"))

        # Append / Prepend
        c1.set("append1", "a,")
        self.assertEquals("a,", c1.get("append1")[0])
        c2.begin_pipeline()
        c2.append("append1", "b,")
        c2.append("append1", "c,")
        c2.append("append1", "d,")
        c2.prepend("append1", "x,")
        c2.prepend("append1", "y,")
        c2.prepend("append1", "z,")
        self.assertEquals("a,", c1.get("append1")[0])
        res = c2.finish_pipeline()
        self.assertEquals(["STORED"] * 6, res)
        self.assertEquals("z,y,x,a,b,c,d,", c1.get("append1")[0])

        # Delete
        c1.set("delete1", "foo")
        c1.set("delete2", "bar")
        self.assertEquals("foo", c1.get("delete1")[0])
        self.assertEquals("bar", c1.get("delete2")[0])
        self.assertEquals(None, c1.get("delete3"))
        c2.begin_pipeline()
#.........这里部分代码省略.........
开发者ID:nanonyme,项目名称:ultramemcache,代码行数:103,代码来源:tests.py


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