mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
Revert "cache get_version results".
Some sources will use the name. This reverts commitsaabf9f5037
andf75a156d46
.
This commit is contained in:
parent
f75a156d46
commit
60afa62d89
2 changed files with 0 additions and 24 deletions
|
@ -38,19 +38,7 @@ def substitute_version(version, name, conf):
|
||||||
# No substitution rules found. Just return the original version string.
|
# No substitution rules found. Just return the original version string.
|
||||||
return version
|
return version
|
||||||
|
|
||||||
_cache = {}
|
|
||||||
|
|
||||||
async def get_version(name, conf, **kwargs):
|
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:
|
for key in handler_precedence:
|
||||||
if key in conf:
|
if key in conf:
|
||||||
func = import_module('.source.' + key, __package__).get_version
|
func = import_module('.source.' + key, __package__).get_version
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
# MIT licensed
|
|
||||||
# Copyright (c) 2018 lilydjwg <lilydjwg@gmail.com>, 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
|
|
Loading…
Add table
Reference in a new issue