A basic Python package to store files in a LRU cache.
Project description
A tool to provide a LRU cache on files.
It has been created to store gigabytes of Thumbor thumbnails on a DigitalOcean server.
Usage
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()
Performance
The performance is not exceptional, but operations basically take a constant time independently of the number of files in the cache, which is not too bad.
Rough benchmarking gave about 170 get per second.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycachu-0.1.1.tar.gz
(3.2 kB
view details)
File details
Details for the file pycachu-0.1.1.tar.gz
.
File metadata
- Download URL: pycachu-0.1.1.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10c5941f555fb996cd1e8fb93fdcfcf73df45a5636f9238f4b1850db95a15ba6 |
|
MD5 | de14aacdbc4c699048daed21a4a2e903 |
|
BLAKE2b-256 | bc20a55db8d8e744344c718b534aee5226cb879b5c813dd099dab0bfc27ca1a3 |