本文整理汇总了Python中flask_cache.Cache.delete_memoized_verhash方法的典型用法代码示例。如果您正苦于以下问题:Python Cache.delete_memoized_verhash方法的具体用法?Python Cache.delete_memoized_verhash怎么用?Python Cache.delete_memoized_verhash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_cache.Cache
的用法示例。
在下文中一共展示了Cache.delete_memoized_verhash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CacheTestCase
# 需要导入模块: from flask_cache import Cache [as 别名]
# 或者: from flask_cache.Cache import delete_memoized_verhash [as 别名]
#.........这里部分代码省略.........
with self.app.test_request_context():
@self.cache.memoize(50)
def big_foo(a, b):
return a+b+random.randrange(0, 100000)
result = big_foo(5, 2)
time.sleep(2)
assert big_foo(5, 2) == result
def test_07_delete_memoize(self):
with self.app.test_request_context():
@self.cache.memoize(5)
def big_foo(a, b):
return a+b+random.randrange(0, 100000)
result = big_foo(5, 2)
result2 = big_foo(5, 3)
time.sleep(1)
assert big_foo(5, 2) == result
assert big_foo(5, 2) == result
assert big_foo(5, 3) != result
assert big_foo(5, 3) == result2
self.cache.delete_memoized(big_foo)
assert big_foo(5, 2) != result
assert big_foo(5, 3) != result2
def test_07b_delete_memoized_verhash(self):
with self.app.test_request_context():
@self.cache.memoize(5)
def big_foo(a, b):
return a+b+random.randrange(0, 100000)
result = big_foo(5, 2)
result2 = big_foo(5, 3)
time.sleep(1)
assert big_foo(5, 2) == result
assert big_foo(5, 2) == result
assert big_foo(5, 3) != result
assert big_foo(5, 3) == result2
self.cache.delete_memoized_verhash(big_foo)
_fname, _fname_instance = function_namespace(big_foo)
version_key = self.cache._memvname(_fname)
assert self.cache.get(version_key) is None
assert big_foo(5, 2) != result
assert big_foo(5, 3) != result2
assert self.cache.get(version_key) is not None
def test_08_delete_memoize(self):
with self.app.test_request_context():
@self.cache.memoize()
def big_foo(a, b):
return a+b+random.randrange(0, 100000)