Let me manage a cache or two for you.

Method __init__ Undocumented
Method new Generates the FIFO queue for a new sort-of LRU cache and returns its index, starting with 0 for the first cache.
Method clear Clears all caches (or just the specified one) of all values (or just the specified value).
Method check Checks cache k for the string x, returning True if it's there or False if not.
Method set Appends x to cache k, which will result in it being found there if checked within N cache misses.
Method _checkIndex Undocumented
def __init__(self, N=40):
Undocumented
def new(self, name=None):

Generates the FIFO queue for a new sort-of LRU cache and returns its index, starting with 0 for the first cache.

def clear(self, k=None, value=None):

Clears all caches (or just the specified one) of all values (or just the specified value).

def _checkIndex(self, k):
Undocumented
def check(self, k, x):

Checks cache k for the string x, returning True if it's there or False if not.

def set(self, k, x):

Appends x to cache k, which will result in it being found there if checked within N cache misses.

The value least recently added (from a cache miss) will be popped off the other end and returned, unless it happens to equal the value just added. (This lets you use it to prune another list somewhere.) Mine isn't strictly an LRU cache, since a cache hit will get drowned in misses.

If nothing was popped off because the cache hasn't yet grown to N elements yet, or the new value equals the popped-off one, the result will be None.

API Documentation for logalyzer, generated by pydoctor at 2021-09-18 08:41:09.