Skip to main content

Handle generic file and directories caching

Project description

xtremcache

xtremcache is a Python package dedicated to handle generic file and directories caching on Windows or Linux. The goal of this module is to be able to cache a file or directory with a unique identifier of your choice and later uncache to a specific location. The directory where the cached files are located is local. The concurrent access (reading and writing) on chached archives is handle by a small data base located in the local data directory.

Installation

xtremcache is available on PyPi.

Tests

Tests are written following unittest framework. Some dependencies are needed (test-requirements.txt). If you want to run tests, enter the following command at the root level of the package:

python -m unittest discover -s tests # All tests
python -m unittest discover -s tests/unit # Unit tests
python -m unittest discover -s tests/integration # Integration tests

Usage

Cache and uncache example

  • Create CacheManager with optional data location and the maximum size in Mo of this cache directory.
  • Cache a directory with unique id to find it lather.
  • Uncache with unique id to a specifique directory.

Python:

from xtremcache.cachemanager import CacheManager

cache_manager = CacheManager(
    cache_dir='/tmp/xtremcache',
    max_size=20_000_000)
cache_manager.cache(
    id='UUID',
    path='/tmp/dir_to_cache')
cache_manager.uncache(
    id='UUID',
    path='/tmp/destination_dir')

Shell:

xtremcache config set cache_dir '/tmp/xtremcache' --local
xtremcache config set max_size '20m' --local
xtremcache cache --id 'UUID' '/tmp/dir_to_cache'
xtremcache uncache --id 'UUID' '/tmp/destination_dir'

Override cached example

  • Create CacheManager with data location and the maximum size in Mo of this cache directory
  • Cache a directory with unique id to find it lather
  • Override last unique id to a new directory

Python:

from xtremcache.cachemanager import CacheManager

cache_manager = CacheManager(
    cache_dir='/tmp/xtremcache',
    max_size=20_000_000)
cache_manager.cache(
    id='UUID',
    path='/tmp/dir_to_cache')
cache_manager.cache(
    id='UUID',
    path='/tmp/new_dir_to_cache',
    force=True)

Shell:

xtremcache config set cache_dir '/tmp/xtremcache' --local
xtremcache config set max_size '20m' --local
xtremcache cache --id 'UUID' '/tmp/dir_to_cache'
xtremcache cache --force --id 'UUID' '/tmp/new_dir_to_cache'

Cache and clean example

  • Create CacheManager with data location and the maximum size in Mo of this cache directory
  • Cache a directory with unique id to find it lather
  • Remove chached file

Python:

from xtremcache.cachemanager import CacheManager

cache_manager = CacheManager(
    cache_dir='/tmp/xtremcache',
    max_size='20m')
cache_manager.cache(
    id='UUID',
    path='/tmp/dir_to_cache')
cache_manager.remove(
    id='UUID')

Shell:

xtremcache config set cache_dir '/tmp/xtremcache' --local
xtremcache config set max_size '20m' --local
xtremcache cache --id 'UUID' '/tmp/dir_to_cache'
xtremcache remove --id 'UUID'

Cache and clean all example

  • Create CacheManager with data location and the maximum size in Mo of this cache directory
  • Cache a directory with unique id to find it lather
  • Remove all chached files

Python:

from xtremcache.cachemanager import CacheManager

cache_manager = CacheManager(
    cache_dir='/tmp/xtremcache',
    max_size='20m')
cache_manager.cache(
    id='UUID',
    path='/tmp/dir_to_cache')
cache_manager.remove()

Shell:

xtremcache config set cache_dir '/tmp/xtremcache' --local
xtremcache config set max_size '20m' --local
xtremcache cache --id 'UUID' '/tmp/dir_to_cache'
xtremcache remove

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

xtremcache-2.2.1.tar.gz (2.7 MB view details)

Uploaded Source

Built Distribution

xtremcache-2.2.1-py3-none-any.whl (2.7 MB view details)

Uploaded Python 3

File details

Details for the file xtremcache-2.2.1.tar.gz.

File metadata

  • Download URL: xtremcache-2.2.1.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for xtremcache-2.2.1.tar.gz
Algorithm Hash digest
SHA256 59528f97838dbe5ed98e66e3f72fd7aaef37f7a916fa5b55a91cbea939fce21f
MD5 1a9aa9c4a5b173ce2453c6877c853528
BLAKE2b-256 87b592e28ca241c31b6d05d34ddd4527159300e2d1239c714be9fd73297486bf

See more details on using hashes here.

File details

Details for the file xtremcache-2.2.1-py3-none-any.whl.

File metadata

  • Download URL: xtremcache-2.2.1-py3-none-any.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for xtremcache-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a611d62b9d38b7ba4f55a86c20e3edb07d24a07e91b1776b57258152a88985c
MD5 97ad90fe23bc181893a9c47b68fc69bb
BLAKE2b-256 e8c1430f17ba9e72c2d875ae67b48e2bec2993d69631ee58ede324c683cd4497

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page