Skip to main content

File based cache for resources and metadata

Reason this release was yanked:

deprecation

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"),
    max_size_bytes=1024 * 1024 * 1024,  # 1GB
    cleanup_interval=timedelta(days=7),
    compression=True
)

# 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.5.2.dev1.tar.gz (30.2 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.5.2.dev1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file pybiocfilecache-0.5.2.dev1.tar.gz.

File metadata

  • Download URL: pybiocfilecache-0.5.2.dev1.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for pybiocfilecache-0.5.2.dev1.tar.gz
Algorithm Hash digest
SHA256 939fa39dbad430e24d3bdf8fb8de234e84b57103085dc548775925e8febecdf6
MD5 6a42bd368d8cf6176a9ea3c0e5b89299
BLAKE2b-256 2fea28d4d98d284dd9aaa4094efccb55c981f974df00baa86def568cc7f53b2e

See more details on using hashes here.

File details

Details for the file pyBiocFileCache-0.5.2.dev1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyBiocFileCache-0.5.2.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 33b65fbd55c8e0b454217c3c6e3b26492bd8ccc98c9107dee0857d75588753b0
MD5 5c2d05112ec64ba2b792cefdf3058980
BLAKE2b-256 e8d8470fa8074ee1572b3feb50bdf917a4efaee9a8fb8aab9fc5225db10b959f

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