Skip to main content

File based cache for resources and metadata

Project description

Project generated with PyScaffold PyPI-Server Unit tests

pyBiocFileCache

pyBiocFileCache is a Python package that provides a robust file caching system with resource validation, cache size management, file compression, and resource tagging. Compatible with BiocFileCache R package.

Installation

Install from PyPI,

pip install pybiocfilecache

Quick Start

from pybiocfilecache import BiocFileCache

# Initialize cache
cache = BiocFileCache("path/to/cache/directory")

# Add a file to cache
resource = cache.add("myfile", "path/to/file.txt")

# Retrieve a file from cache
resource = cache.get("myfile")

# Use the cached file
print(resource["rpath"])  # Path to cached file

Advanced Usage

Configuration

from pybiocfilecache import BiocFileCache, CacheConfig
from datetime import timedelta
from pathlib import Path

# Create custom configuration
config = CacheConfig(
    cache_dir=Path("cache_directory"),
    cleanup_interval=timedelta(days=7),
)

# Initialize cache with configuration
cache = BiocFileCache(config=config)

Resource Management

# Add file with tags and expiration
from datetime import datetime, timedelta

resource = cache.add(
    "myfile",
    "path/to/file.txt",
    tags=["data", "raw"],
    expires=datetime.now() + timedelta(days=30)
)

# List resources by tag
resources = cache.list_resources(tag="data")

# Search resources
results = cache.search("myfile", field="rname")

# Update resource
cache.update("myfile", "path/to/new_file.txt")

# Remove resource
cache.remove("myfile")

Cache Statistics and Maintenance

# Get cache statistics
stats = cache.get_stats()
print(stats)

# Clean up expired resources
removed_count = cache.cleanup()

# Purge entire cache
cache.purge()

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

pybiocfilecache-0.7.0.tar.gz (29.6 kB view details)

Uploaded Source

Built Distribution

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

pybiocfilecache-0.7.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pybiocfilecache-0.7.0.tar.gz.

File metadata

  • Download URL: pybiocfilecache-0.7.0.tar.gz
  • Upload date:
  • Size: 29.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybiocfilecache-0.7.0.tar.gz
Algorithm Hash digest
SHA256 ff60d0727f64de1de6fb915c4d3c400703b94b8cf5e3dc84c7b9cc9ced836b60
MD5 3843c8b1794cca49a73cd13868d90058
BLAKE2b-256 05c6c2f0bad4849d7e7af99d49f68c899c0b0c33cf7a1ce6ae2756f403db098c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybiocfilecache-0.7.0.tar.gz:

Publisher: publish-pypi.yml on BiocPy/pyBiocFileCache

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

File details

Details for the file pybiocfilecache-0.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pybiocfilecache-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4740ee7b1d3d503eab65e0ca1ca4dd97bb5eb76353fdc1eff700159bb15a07ae
MD5 b99d3fe25aa7132ce189174bf7dea81e
BLAKE2b-256 3d8aa645dcf9097bdd75012be719b2b3061907ae61197d26e8d39e8e4317faee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybiocfilecache-0.7.0-py3-none-any.whl:

Publisher: publish-pypi.yml on BiocPy/pyBiocFileCache

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