在lru缓存中存储文件的基本python包。
pycachu的Python项目详细描述
在文件上提供lru缓存的工具。
它是为在DigitalOcean服务器上存储千兆字节的缩略图而创建的。
用法
from pycachu import Pycachu # Initialize the cache # The dir has to exist p = Pycachu('/storage/pycachu', 20 * (1024 ** 3)) # Get a file f = p.get('/some/file') if f is not None: yield f f.close() else: content = generate_file_content() p.put('/some/file', content) content.seek(0) yield content content.close()
性能
性能并不例外,但操作基本上需要一个独立于 缓存中的文件数,这还不错。
粗略的基准测试大约每秒获得170个get。