本文整理汇总了Python中celery.utils.functional.LRUCache.keys方法的典型用法代码示例。如果您正苦于以下问题:Python LRUCache.keys方法的具体用法?Python LRUCache.keys怎么用?Python LRUCache.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.utils.functional.LRUCache
的用法示例。
在下文中一共展示了LRUCache.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_least_recently_used
# 需要导入模块: from celery.utils.functional import LRUCache [as 别名]
# 或者: from celery.utils.functional.LRUCache import keys [as 别名]
def test_least_recently_used(self):
x = LRUCache(3)
x[1], x[2], x[3] = 1, 2, 3
self.assertEqual(list(x.keys()), [1, 2, 3])
x[4], x[5] = 4, 5
self.assertEqual(list(x.keys()), [3, 4, 5])
# access 3, which makes it the last used key.
x[3]
x[6] = 6
self.assertEqual(list(x.keys()), [5, 3, 6])
x[7] = 7
self.assertEqual(list(x.keys()), [3, 6, 7])
示例2: test_update_expires
# 需要导入模块: from celery.utils.functional import LRUCache [as 别名]
# 或者: from celery.utils.functional.LRUCache import keys [as 别名]
def test_update_expires(self):
limit = 100
x = LRUCache(limit=limit)
slots = list(range(limit * 2))
for i in slots:
x.update({i: i})
self.assertListEqual(list(x.keys()), list(slots[limit:]))
示例3: test_expires
# 需要导入模块: from celery.utils.functional import LRUCache [as 别名]
# 或者: from celery.utils.functional.LRUCache import keys [as 别名]
def test_expires(self):
limit = 100
x = LRUCache(limit=limit)
slots = list(range(limit * 2))
for i in slots:
x[i] = i
self.assertListEqual(list(x.keys()), list(slots[limit:]))
self.assertTrue(x.items())
self.assertTrue(x.values())
示例4: test_update_larger_than_cache_size
# 需要导入模块: from celery.utils.functional import LRUCache [as 别名]
# 或者: from celery.utils.functional.LRUCache import keys [as 别名]
def test_update_larger_than_cache_size(self):
x = LRUCache(2)
x.update(dict((x, x) for x in range(100)))
self.assertEqual(list(x.keys()), [98, 99])