Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bottle_file_cache-1.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bottle_file_cache-1.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for bottle_file_cache-1.1.0.tar.gz
Algorithm Hash digest
SHA256 016221690721693807923747406fb9cf344ac3746549bf7d8005e0495078cb3e
MD5 5bbaa3180a9d93eb60f9b92a8005addd
BLAKE2b-256 79d195f3f314af396c92798522505b8053f0f0b4b2715804da763ce95ffecabd

See more details on using hashes here.

Provenance

The following attestation bundles were made for bottle_file_cache-1.1.0.tar.gz:

Publisher: release.yml on BoboTiG/bottle-file-cache

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bottle_file_cache-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bottle_file_cache-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 05f7c6f74d8f0be57169244494fabdc4b203835c39b142bfc999a8fbd7beb4c2
MD5 cc8b0f7f9faa0bf324855baf5abc6e78
BLAKE2b-256 a5151a76929417440e92fe6dab225f296124534dd78c6936294e5df3fa54fb45

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page