Skip to main content

SQLite cache storage for botasaurus.

Project description

sqlite-cache-storage

SQLite cache storage backend for botasaurus.

Installation

pip install sqlite-cache-storage

Usage

With decorators like @task, @request, @browser

from sqlite_cache_storage import SqliteCacheStorage
from botasaurus.task import task
from datetime import timedelta

# Create storage instance
sqlite_storage = SqliteCacheStorage(
    db_path="cache.db"
)

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

With @cache decorator

from sqlite_cache_storage import SqliteCacheStorage
from botasaurus.decorator_helpers import cache
from datetime import timedelta

# Create storage instance
sqlite_storage = SqliteCacheStorage(
    db_path="cache.db"
)

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

API

SqliteCacheStorage

SqliteCacheStorage(
    db_path: str = 'cache.db',
    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

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

sqlite_cache_storage-1.0.2.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file sqlite_cache_storage-1.0.2.tar.gz.

File metadata

  • Download URL: sqlite_cache_storage-1.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for sqlite_cache_storage-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d44a059445975c101c99435cc8dfaa1a3e880d90e1cdb04ec43533bbc8ec67a9
MD5 0b63f56e1723413f95efc12bd0674139
BLAKE2b-256 f25db7a81bbc639e491868e88593e3801c2a9761b9b83709d0b8b0de05777d49

See more details on using hashes here.

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