Ejemplo n.º 1
0
 def test_set(self):
     CacheBase.configure("apps.core.cache.redis.RedisCache",
                         defaults=options.cache_options)
     cache = CacheBase(self.io_loop)
     yield cache.set("testkey", "value")
     value = yield cache.get("testkey",)
     self.assertEqual(value, "value")
     yield cache.delete("testkey")
     value = yield cache.get("testkey",)
     self.assertEqual(value, None)
Ejemplo n.º 2
0
    def test_set_dict(self):
        CacheBase.configure("apps.core.cache.redis.RedisCache",
                            defaults=options.cache_options)
        cache = CacheBase(self.io_loop)

        obj = {"asd": 123, "zxc": "qwe"}
        yield cache.set("testkey", obj)
        value = yield cache.get("testkey",)
        self.assertEqual(isinstance(value, dict), True)
        self.assertItemsEqual(value, {"asd": 123, "zxc": "qwe"})
        yield cache.delete("testkey")
        value = yield cache.get("testkey",)
        self.assertEqual(value, None)
Ejemplo n.º 3
0
    def test_set_object(self):
        CacheBase.configure("apps.core.cache.redis.RedisCache",
                            defaults=options.cache_options)
        cache = CacheBase(self.io_loop)

        obj = A(123123)
        yield cache.set("testkey", obj)
        value = yield cache.get("testkey",)
        self.assertEqual(isinstance(value, A), True)
        self.assertEqual(value.arg, 123123)
        yield cache.delete("testkey")
        value = yield cache.get("testkey",)
        self.assertEqual(value, None)