Skip to main content

A simple URL caching library for Python

Project description

sam_url_cache

A simple Python package for caching the contents of URLs using SQLite. This helps avoid repeated network requests for the same URL.

Features

  • Caches URL responses in a local SQLite database.
  • Automatically fetches and stores content on cache miss.
  • Simple API for checking if a URL has been seen before.

Installation

Install via pip

pip install sam-url-cache

Usage

from sam_url_cache import URLCache

cache = URLCache()  # Uses default database path 'url_cache.db'

# Fetch and cache a URL
content = cache.get_url('https://example.com')

# Check if a URL has been seen before
if cache.seen_before('https://example.com'):
    print("URL is cached!")

Object

URLCache(databse_path: str = 'url_cache.db')

Create a new URL cache instance. Optionally specify a custom database path.

get_url(url: str) -> str

Fetch the content of the URL. Returns cached content if available, otherwise fetches from the web and caches it.

seen_before(url: str) -> bool

Check if the URL is already cached.

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

sam_url_cache-0.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

sam_url_cache-0.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file sam_url_cache-0.4.tar.gz.

File metadata

  • Download URL: sam_url_cache-0.4.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.2

File hashes

Hashes for sam_url_cache-0.4.tar.gz
Algorithm Hash digest
SHA256 be1dff4caa429c8c5a5ba8ecd42ca1e7927007e5ca63d51b8b847544f520356e
MD5 8274a50358c713faf74a4221af706d08
BLAKE2b-256 21ecaee894c73f552102a438e11701ee69add69e7dd65c82414eae3adbbf556c

See more details on using hashes here.

File details

Details for the file sam_url_cache-0.4-py3-none-any.whl.

File metadata

  • Download URL: sam_url_cache-0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.2

File hashes

Hashes for sam_url_cache-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e70269c306a7aa53a2a81bb129d0b6dda8357527bc3287f3bd94c9f6eb17935d
MD5 a57b45d374511f9fb346bca926cf4e10
BLAKE2b-256 a57926150a2b7faef7ba8ced3a703264fc181651ae92ad41c2eca5ed75dfb6da

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