我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用charmhelpers.core.hookenv.cache()。
def tearDown(self): # Reset cached cache hookenv.cache = {}
def tearDown(self): # Reset @cached cache hookenv.cache = {}
def _clean_globals(): hookenv.cache.clear() del hookenv._atstart[:] del hookenv._atexit[:]
def test_relation_set_flushes_local_unit_cache(self, check_output, check_call, local_unit): check_output.return_value = json.dumps('BAR').encode('UTF-8') local_unit.return_value = 'baz_unit' hookenv.relation_get(attribute='baz_scope', unit='baz_unit') hookenv.relation_get(attribute='bar_scope') self.assertTrue(len(hookenv.cache) == 2) check_output.return_value = "" hookenv.relation_set(baz_scope='hello') # relation_set should flush any entries for local_unit self.assertTrue(len(hookenv.cache) == 1)