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.

PYPI

https://pypi.org/project/sam-url-cache/

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.7.tar.gz (3.5 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.7-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sam_url_cache-0.7.tar.gz
Algorithm Hash digest
SHA256 05c1c110f6f29dee83aa1440380aeac97df2bf87ab1f702194e43ac058d9752a
MD5 4292d36fb8a0c00ffb4d4f164ae3f5f8
BLAKE2b-256 20373caed9dbf282d8c2e1c614181aaaf8df17c09afd0e290508649aec2e628a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for sam_url_cache-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c441695982e47984b741ebfc71b65e3b775b682c81416e5d0f24be9ec0c1a781
MD5 927ff5cc9c8b906307abee3bbc099fb6
BLAKE2b-256 220b999486842c72c20adf51901296f3c1cbd8409457753f0b9af32f272009fa

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