A simple file cache for the Python Bottle web framework.
Project description
Bottle File Cache
A simple file cache for the Python Bottle web framework.
Installation
python -m pip install -U bottle-file-cache
Usage
Given that example:
import bottle
@bottle.route("/hello/<name>")
def index(name: str) -> str:
return bottle.template("<b>Hello {{name}}</b>!", name=name)
if __name__ == "__main__":
bottle.run(host="localhost", port=8080)
Add those lines to enable the cache:
+from bottle_file_cache import cache
import bottle
@bottle.route("/hello/<name>")
+@cache()
def index(name: str) -> str:
return bottle.template("<b>Hello {{name}}</b>!", name=name)
And that's it!
Advanced Usage
Bottle Parameters
You can specify more details to compute the cache key.
Here, it takes URL parameters in addition to the request path:
@bottle.route("/hello2/<name>")
@cache(params=["gender", "pron", "not-used"])
def index2(name: str) -> str:
return bottle.template("<b>Hello {{name}} ({{gender}}, {{pron}})</b>!", name=name, **bottle.request.params)
Par-Call Expiration
You can specify a custom expiration time (in seconds) on a per-call basis:
@bottle.route("/hello3/<name>")
@cache(expires=1)
def index3(name: str) -> str:
return bottle.template("<b>Hello {{name}}</b>!", name=name)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bottle_file_cache-1.1.0.tar.gz.
File metadata
- Download URL: bottle_file_cache-1.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
016221690721693807923747406fb9cf344ac3746549bf7d8005e0495078cb3e
|
|
| MD5 |
5bbaa3180a9d93eb60f9b92a8005addd
|
|
| BLAKE2b-256 |
79d195f3f314af396c92798522505b8053f0f0b4b2715804da763ce95ffecabd
|
Provenance
The following attestation bundles were made for bottle_file_cache-1.1.0.tar.gz:
Publisher:
release.yml on BoboTiG/bottle-file-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bottle_file_cache-1.1.0.tar.gz -
Subject digest:
016221690721693807923747406fb9cf344ac3746549bf7d8005e0495078cb3e - Sigstore transparency entry: 566328541
- Sigstore integration time:
-
Permalink:
BoboTiG/bottle-file-cache@55c10e5afa2d6baabbe5eb1da393ae8cf8117c5f -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/BoboTiG
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c10e5afa2d6baabbe5eb1da393ae8cf8117c5f -
Trigger Event:
push
-
Statement type:
File details
Details for the file bottle_file_cache-1.1.0-py3-none-any.whl.
File metadata
- Download URL: bottle_file_cache-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05f7c6f74d8f0be57169244494fabdc4b203835c39b142bfc999a8fbd7beb4c2
|
|
| MD5 |
cc8b0f7f9faa0bf324855baf5abc6e78
|
|
| BLAKE2b-256 |
a5151a76929417440e92fe6dab225f296124534dd78c6936294e5df3fa54fb45
|
Provenance
The following attestation bundles were made for bottle_file_cache-1.1.0-py3-none-any.whl:
Publisher:
release.yml on BoboTiG/bottle-file-cache
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bottle_file_cache-1.1.0-py3-none-any.whl -
Subject digest:
05f7c6f74d8f0be57169244494fabdc4b203835c39b142bfc999a8fbd7beb4c2 - Sigstore transparency entry: 566328550
- Sigstore integration time:
-
Permalink:
BoboTiG/bottle-file-cache@55c10e5afa2d6baabbe5eb1da393ae8cf8117c5f -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/BoboTiG
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@55c10e5afa2d6baabbe5eb1da393ae8cf8117c5f -
Trigger Event:
push
-
Statement type: