How to use the aiocache.caches.create 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 / test_factory.py View on Github external
def test_create_cache_class_no_alias(self):
        cache = caches.create(cache=RedisCache)

        assert isinstance(cache, RedisCache)
        assert cache.endpoint == "127.0.0.1"
        assert cache.port == 6379
github argaen / aiocache / tests / ut / test_factory.py View on Github external
def test_create_deprecated(self):
        with patch("aiocache.factory.warnings.warn") as mock:
            caches.create(cache="aiocache.SimpleMemoryCache")

        mock.assert_called_once_with(
            "Creating a cache with an explicit config is deprecated, use 'aiocache.Cache'",
            DeprecationWarning,
        )
github argaen / aiocache / tests / ut / test_factory.py View on Github external
def test_get_wrong_alias(self):
        with pytest.raises(KeyError):
            caches.get("wrong_cache")

        with pytest.raises(KeyError):
            caches.create("wrong_cache")
github argaen / aiocache / tests / ut / test_factory.py View on Github external
caches.set_config(
            {
                "default": {
                    "cache": "aiocache.RedisCache",
                    "plugins": [
                        {"class": "aiocache.plugins.HitMissRatioPlugin"},
                        {"class": "aiocache.plugins.TimingPlugin"},
                    ],
                }
            }
        )

        cache = caches.get("default")
        assert isinstance(cache.plugins[0], HitMissRatioPlugin)

        cache = caches.create("default")
        assert isinstance(cache.plugins[0], HitMissRatioPlugin)
github argaen / aiocache / tests / ut / test_factory.py View on Github external
def test_create_cache_str_no_alias(self):
        cache = caches.create(cache="aiocache.RedisCache")

        assert isinstance(cache, RedisCache)
        assert cache.endpoint == "127.0.0.1"
        assert cache.port == 6379
github argaen / aiocache / tests / ut / test_factory.py View on Github external
def test_create_cache_ensure_alias_or_cache(self):
        with pytest.raises(TypeError):
            caches.create()