How to use the aiocache.RedisCache function in aiocache

To help you get started, we’ve selected a few aiocache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github argaen / aiocache / tests / ut / backends / test_redis.py View on Github external
def test_default_serializer(self):
        assert isinstance(RedisCache().serializer, JsonSerializer)
github argaen / aiocache / tests / ut / test_factory.py View on Github external
def test_class_from_string():
    assert _class_from_string("aiocache.RedisCache") == RedisCache
github argaen / aiocache / tests / integration / test_cache_settings.py View on Github external
def test_cache_settings(self):
        settings.set_cache(
            RedisCache, endpoint="127.0.0.1", port=6379, timeout=10, db=1)
        cache = RedisCache(db=0)

        assert cache.endpoint == "127.0.0.1"
        assert cache.port == 6379
        assert cache.timeout == 10
        assert cache.db == 0
github argaen / aiocache / tests / ut / test_utils.py View on Github external
def test_get_cache_overrides(self):
        cache = get_cache(
            cache=RedisCache, namespace="default", serializer=PickleSerializer(),
            plugins=BasePlugin(), endpoint="http://...", port=123)

        assert isinstance(cache, RedisCache)
        assert cache.endpoint == "http://..."
        assert cache.port == 123
        assert cache.namespace == "default"
        assert isinstance(cache.serializer, PickleSerializer)
        assert isinstance(cache.plugins, BasePlugin)
github argaen / aiocache / tests / ut / test_factory.py View on Github external
"endpoint": "127.0.0.10",
                    "port": 6378,
                    "serializer": {"class": "aiocache.serializers.PickleSerializer"},
                    "plugins": [
                        {"class": "aiocache.plugins.HitMissRatioPlugin"},
                        {"class": "aiocache.plugins.TimingPlugin"},
                    ],
                },
                "alt": {"cache": "aiocache.SimpleMemoryCache"},
            }
        )

        default = caches.get("default")
        alt = caches.get("alt")

        assert isinstance(default, RedisCache)
        assert default.endpoint == "127.0.0.10"
        assert default.port == 6378
        assert isinstance(default.serializer, PickleSerializer)
        assert len(default.plugins) == 2

        assert isinstance(alt, SimpleMemoryCache)
github argaen / aiocache / tests / ut / test_utils.py View on Github external
def test_get_cache_value_with_fallbacks_with_settings():
    settings.set_cache(RedisCache, fake_key="random")
    assert get_cache_value_with_fallbacks(None, "fake_key", "DEFAULT", cls=RedisCache) == "random"
github argaen / aiocache / examples / config_default_cache.py View on Github external
@cached(cache=RedisCache, ttl=10, key="key")
async def decorator():
    return Result("content", 200)
github argaen / aiocache / examples / config_default_cache.py View on Github external
def test_default_cache():
    loop = asyncio.get_event_loop()
    loop.run_until_complete(decorator())
    loop.run_until_complete(global_cache())

    loop.run_until_complete(RedisCache(namespace="main").delete("key"))