support no expire in getcache

This commit is contained in:
Emmanuel Garette 2013-09-07 22:37:13 +02:00
parent 632de1cffb
commit 3dc72c505c
2 changed files with 13 additions and 1 deletions

View File

@ -42,6 +42,18 @@ def test_get_cache():
assert c.u1 == [100] assert c.u1 == [100]
def test_get_cache_no_expire():
# force a value in cache, try if reget corrupted value
od1 = make_description()
c = Config(od1)
values = c.cfgimpl_get_values()
settings = c.cfgimpl_get_settings()
settings._p_.setcache('u1', set(['inject2']), None)
assert 'inject2' in settings[od1.u1]
values._p_.setcache('u1', 200, None)
assert c.u1 == [200]
def test_cache_reset(): def test_cache_reset():
od1 = make_description() od1 = make_description()
c = Config(od1) c = Config(od1)

View File

@ -32,7 +32,7 @@ class Cache(object):
def getcache(self, path, exp): def getcache(self, path, exp):
value, created = self._cache[path] value, created = self._cache[path]
if exp <= created: if created is None or exp <= created:
return True, value return True, value
return False, None return False, None