Hi,
I tried to use cache._cache in another function and realized that this throws an AttributeError because _cache is not defined and that everything inside the try/except is actually incorrect and the code works because it always goes to the except branch. If you change cache._cache to just be cache it will actually break the code - replacing the whole content of the function by cache.set(key, cache.get(key, 0) + 1, self.expire_after()) fixes it.
Just something to be aware of.