本文整理汇总了Python中mako.util.LRUCache方法的典型用法代码示例。如果您正苦于以下问题:Python util.LRUCache方法的具体用法?Python util.LRUCache怎么用?Python util.LRUCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mako.util
的用法示例。
在下文中一共展示了util.LRUCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testlru
# 需要导入模块: from mako import util [as 别名]
# 或者: from mako.util import LRUCache [as 别名]
def testlru(self):
l = LRUCache(10, threshold=0.2)
for id_ in range(1, 20):
l[id_] = item(id_)
# first couple of items should be gone
assert 1 not in l
assert 2 not in l
# next batch over the threshold of 10 should be present
for id_ in range(11, 20):
assert id_ in l
l[12]
l[15]
l[23] = item(23)
l[24] = item(24)
l[25] = item(25)
l[26] = item(26)
l[27] = item(27)
assert 11 not in l
assert 13 not in l
for id_ in (25, 24, 23, 14, 12, 19, 18, 17, 16, 15):
assert id_ in l
示例2: testlru
# 需要导入模块: from mako import util [as 别名]
# 或者: from mako.util import LRUCache [as 别名]
def testlru(self):
l = LRUCache(10, threshold=.2)
for id in range(1,20):
l[id] = item(id)
# first couple of items should be gone
assert 1 not in l
assert 2 not in l
# next batch over the threshold of 10 should be present
for id in range(11,20):
assert id in l
l[12]
l[15]
l[23] = item(23)
l[24] = item(24)
l[25] = item(25)
l[26] = item(26)
l[27] = item(27)
assert 11 not in l
assert 13 not in l
for id in (25, 24, 23, 14, 12, 19, 18, 17, 16, 15):
assert id in l