DiskCache: Disk and File-based Cache
Rationale: file-based cache in Django is essentially broken. Culling files is too costly. Large caches are forced to scan lots of files and do lots of deletes on some operations. Takes too long in the request/response cycle.
Solution: Each operation, “set” and “del” should delete at most two to ten expired keys.
Each “get” needs only check expiry and delete if needed. Make it speedy.
If only we had some kind of file-based database… we do! It’s called SQLite. For metadata and small stuff, use SQLite and for bigger things use files.
Features
Pure-Python
Developed on Python 2.7
Tested on CPython 2.6, 2.7, 3.3, 3.4, 3.5 and PyPy, PyPy3
Get full_path reference to value.
Allow storing raw data.
Small values stored in database.
Leverages SQLite native types: int, float, unicode, blob.
Thread-safe and process-safe.
Multiple eviction policies - Least-Recently-Stored - Least-Recently-Used - Least-Frequently-Used
Stampede barrier decorator.
Metadata support for “tag” to evict a group of keys at once.
Quickstart
Installing DiskCache is simple with pip:
$ pip install diskcache
You can access documentation in the interpreter with Python’s built-in help function:
>>> from diskcache import DjangoCache >>> help(DjangoCache)
Caveats
Types matter in key equality comparisons. Comparisons like 1 == 1.0 and b'abc' == u'abc' return False.
Tutorial
TODO
Reference and Indices
License
Copyright 2016 Grant Jenks
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Metadata
Release files for diskcache 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| diskcache-0.7.0.tar.gz | 126.9 kB | Without provenance | Details for diskcache-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| diskcache-0.7.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for diskcache-0.7.0-py2.py3-none-any.whl |
Total release size: 140.7 kB
Release files / diskcache-0.7.0.tar.gz
| Download URL | diskcache-0.7.0.tar.gz |
|---|---|
| Size | 126.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c64e23e10ced8ee864800f773f298b10d3c618714f2f29b14d48bf9b12f35d1
|
|
BLAKE2b-256 checksum How to use checksums |
17ef6ae176da5f7827b0999b2f4c65f74a023d88ce2c014e5e764e01b230584b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / diskcache-0.7.0-py2.py3-none-any.whl
| Download URL | diskcache-0.7.0-py2.py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
22605140f677fdaf5c3f75dea45219c810882ee56c640fb6547c1f07f849facc
|
|
BLAKE2b-256 checksum How to use checksums |
491a653603c742254c280a6296766af8722d5a211bde83a810434a7b5c3f8584
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for diskcache 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.