Skip to content

Instantly share code, notes, and snippets.

View Beandnot's full-sized avatar

Don Beandnot

  • ZhengZhou,China
View GitHub Profile
@Beandnot
Beandnot / MidpointLruCache.py
Created May 16, 2020 03:07 — forked from midom/MidpointLruCache.py
LRU with midpoint insertion (LRU2Q) cache decorator for Python
class MidpointLruCache:
def __init__(self, size, oldpercentage):
self.size = size
self.oldsize = size * oldpercentage / 100
self.youngsize = size * (100 - oldpercentage) / 100
self.youngitems = collections.OrderedDict()
self.olditems = collections.OrderedDict()
def __call__(self, func):