Skip to main content

CACHE GUIOSOFT

Caching data using files, Redis or local SQLite

codecov Codecov push

[codecov]

Upload Python Package

Local files for caching

from cache_gs import CacheGS

# Storage on local directory

file_cache = CacheGS('path://directory_for_cache_storage')

# Storage on local SQLite database

slite_cache = CacheGS('sqlite://directory_or_file_for_storage')

# Storage on Redis

redis_cache = CacheGS('redis://host:6379')

[More options for redis](#Redis options and example)

Usage

Like INI files, data is grouped in section/key names.

Installing

pip install cache-guiosoft

Writing value

cache.set_value(section, key, value, ttl: int = 0)

# ttl is the life time of value in seconds from the time is created

Reading value

value = cache.get_value(section, key, default=None)

Deleting value

cache.delete_value(section, key)

Purging expired data

  • On Redis cache, this is handled by the server, automatically.
  • On SQLite cache, purging is executing on every instantiation.
  • On Local File cache, purging is automatically executed once a day, checked on every instantiation.

Force purging expired data

cache.purge_expired()

Redis options and example

Redis connection uses the redis-py component from Andy McCurdy. You can use the same connection strings that the Redis class uses:

  • redis://[[username]:[password]]@localhost:6379/0

  • rediss://[[username]:[password]]@localhost:6379/0

  • unix://[[username]:[password]]@/path/to/socket.sock?db=0

      Three URL schemes are supported:
    
      - ```redis://``
        <http://www.iana.org/assignments/uri-schemes/prov/redis>`_ creates a
        normal TCP socket connection
      - ```rediss://``
        <http://www.iana.org/assignments/uri-schemes/prov/rediss>`_ creates a
        SSL wrapped TCP socket connection
      - ``unix://`` creates a Unix Domain Socket connection
    
      There are several ways to specify a database number. The parse function
      will return the first specified option:
          1. A ``db`` querystring option, e.g. redis://localhost?db=0
          2. If using the redis:// scheme, the path argument of the url, e.g.
             redis://localhost/0
          3. The ``db`` argument to this function.
    
      If none of these options are specified, db=0 is used.
    

Redis on docker

docker-compose.yaml

redis:
    container_name: 'redis'
    image: 'redis:4-alpine'
    command: redis-server --requirepass 1234
    ports:
        - '6379:6379'

For testing, just run:

docker-compose up

Metadata

Release files for cache-guiosoft 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cache-guiosoft 0.0.7
File Size Uploaded Provenance Actions
cache-guiosoft-0.0.7.tar.gz 14.5 kB Without provenance Details for cache-guiosoft-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cache-guiosoft 0.0.7
File Interpreter ABI Platform Actions
cache_guiosoft-0.0.7-py3-none-any.whl Python 3 none any Details for cache_guiosoft-0.0.7-py3-none-any.whl

Total release size: 36.7 kB

Release files / cache-guiosoft-0.0.7.tar.gz

Download URL cache-guiosoft-0.0.7.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6edda9bb75151c242992ceb07c979844d04826d7baa24d2b37791d2b3b0dce0a
BLAKE2b-256 checksum
How to use checksums
842aa3f64299f2d3e4838e68c3fea7c42582f7e5c8163ee690f160a3c625a069
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Release files / cache_guiosoft-0.0.7-py3-none-any.whl

Download URL cache_guiosoft-0.0.7-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58fdc528bc0c8331015e10e811675f5481031d21f7d15f386cf603fda8dceb7f
BLAKE2b-256 checksum
How to use checksums
fb7d45aee661e68b68d53deaf71fbce2f670a738365b5000adea2b6be092a4ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

Security for cache-guiosoft 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page