Skip to main content

pg-cache-storage

PostgreSQL cache storage backend for botasaurus.

Installation

pip install pg-cache-storage

Usage

With decorators like @task, @request, @browser

from pg_cache_storage import PostgresCacheStorage
from botasaurus.task import task
from datetime import timedelta

# Create storage instance
pg_storage = PostgresCacheStorage(
    host="localhost",
    port=5432,
    username="postgres",
    password="postgres",
    db_name="cache"
)

@task(cache=True, expires_in=timedelta(days=1), cache_storage=pg_storage)
def my_scraper(data):
    # scraping logic
    return result

With @cache decorator

from pg_cache_storage import PostgresCacheStorage
from botasaurus.decorator_helpers import cache
from datetime import timedelta

# Create storage instance
pg_storage = PostgresCacheStorage(
    host="localhost",
    port=5432,
    username="postgres",
    password="postgres",
    db_name="cache"
)

# Use the decorator
@cache(expires_in=timedelta(days=1), cache_storage=pg_storage)
def my_function(data):
    # time-consuming operation
    return result

API

PostgresCacheStorage

PostgresCacheStorage(
    host: str = 'localhost',
    port: int = 5432,
    username: str = 'postgres',
    password: str = 'postgres',
    db_name: str = 'cache',
    table_name: str = 'botasaurus_cache'
)

Methods

  • get(func_name, key_data, expires_in=None) - Get cached value. Returns {"data": value} or None
  • put(func_name, key_data, data) - Store value in cache
  • delete(func_name, key_data) - Delete cached value

License

MIT

Metadata

Release files for pg-cache-storage 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pg-cache-storage 1.0.5
File Size Uploaded Provenance Actions
pg_cache_storage-1.0.5.tar.gz 4.2 kB Without provenance Details for pg_cache_storage-1.0.5.tar.gz

Release files / pg_cache_storage-1.0.5.tar.gz

Download URL pg_cache_storage-1.0.5.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f602be8d68f335bc02c7e4fdaa20f9d6720c60151b7d801fbc4f96d04cd6e25e
BLAKE2b-256 checksum
How to use checksums
882b241310110c2bcaece9b2176e3dd8cc508a5e458f64f15a0d46c14c268ea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for pg-cache-storage 1.0.5

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page