本文整理匯總了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)