Yet another in-memory caching package
- Free software: MIT license
- Documentation: https://yamicache.readthedocs.io.
- Memoization
- Selective caching based on decorators
- Mutli-threaded support
- Optional garbage collection thread
- Optional time-based cache expiration
from __future__ import print_function
import time
from yamicache import Cache
c = Cache()
class MyApp(object):
@c.cached()
def long_op(self):
time.sleep(30)
return 1
app = MyApp()
t_start = time.time()
assert app.long_op() == 1 # takes 30s
assert app.long_op() == 1 # takes 0s
assert app.long_op() == 1 # takes 0s
assert 1 < (time.time() - t_start) < 31