Beispiel #1
0
    def test_multi_cmd(self):
        key = uuid.uuid4().hex
        client = Client(['127.0.0.1:11211'])
        yield client.set(key, {'foo': 1, 'bar': {'test': 'test'}})
        res = yield client.get(key)
        self.assertEqual(res, {'foo': 1, 'bar': {'test': 'test'}})
        yield client.delete(key)

        yield client.set('test1', 'test1')
        yield client.set('test2', 'test2')
        res1 = yield client.get('test1')
        self.assertEqual(res1, 'test1')

        yield client.set_multi({'foo': 1, 'bar': 'bar'}, 5, key_prefix='test_')
        yield client.set_multi({'0001': 1, '0002': 2}, 5, key_prefix='test_')
        yield client.delete('test_foo')
        res2 = yield client.get_multi(['foo', 'bar', '0001', '0002'],
                                      key_prefix='test_')
        self.assertEqual(res2, {'0001': 1, '0002': 2, 'bar': 'bar'})
Beispiel #2
0
 def test_delete_exist(self):
     client = Client(['127.0.0.1:11211'])
     key = uuid.uuid4().hex
     yield client.set(key, 'value', 5)
     res = yield client.delete(key)
     self.assertEqual(res, True)
Beispiel #3
0
 def test_delete_not_exist(self):
     client = Client(['127.0.0.1:11211'])
     key = uuid.uuid4().hex
     res = yield client.delete(key)
     self.assertEqual(res, True)