From 60afa62d896dcbda54563b20c763e1f53243873f Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sat, 22 Sep 2018 13:35:42 +0800 Subject: [PATCH] Revert "cache get_version results". Some sources will use the name. This reverts commits aabf9f503784321f026e6028a5c5ff6066d4cfda and f75a156d46f7fa94349ca1c80c255ece0a55b59f. --- nvchecker/get_version.py | 12 ------------ tests/test_cache.py | 12 ------------ 2 files changed, 24 deletions(-) delete mode 100644 tests/test_cache.py diff --git a/nvchecker/get_version.py b/nvchecker/get_version.py index 7824790..96be522 100644 --- a/nvchecker/get_version.py +++ b/nvchecker/get_version.py @@ -38,19 +38,7 @@ def substitute_version(version, name, conf): # No substitution rules found. Just return the original version string. return version -_cache = {} - async def get_version(name, conf, **kwargs): - cache_key = sorted(conf.items()) + sorted(kwargs.items()) - cache_key = tuple(cache_key) - if cache_key in _cache: - return _cache[cache_key] - - version = await _get_version_real(name, conf, **kwargs) - _cache[cache_key] = version - return version - -async def _get_version_real(name, conf, **kwargs): for key in handler_precedence: if key in conf: func = import_module('.source.' + key, __package__).get_version diff --git a/tests/test_cache.py b/tests/test_cache.py deleted file mode 100644 index 455fd54..0000000 --- a/tests/test_cache.py +++ /dev/null @@ -1,12 +0,0 @@ -# MIT licensed -# Copyright (c) 2018 lilydjwg , et al. - -import pytest -pytestmark = pytest.mark.asyncio - -async def test_cache(get_version): - a = await get_version("a", {"cmd": "date +%%N"}) - b = await get_version("b", {"cmd": "date +%%N"}) - c = await get_version("c", {"cmd": "date"}) - assert a == b - assert a != c