No project description provided
Project description
CACHE GUIOSOFT
Caching data using files, Redis or local SQLite
[]
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?arg=value&arg2=value2')
Usage
Like INI files, data is grouped in section/key names.
Writing value
cache.set_value(section, key, value, valid_until: int = 0, expires_in: int = 0)
# valid_until is a real timestamp
# expires_in 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, purgin is automatically executed once a day, checked on every instantiation.
Force purging expired data
cache.purge_expired()
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
cache-guiosoft-0.0.4.tar.gz
(12.4 kB
view hashes)
Built Distribution
Close
Hashes for cache_guiosoft-0.0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d77a592f582daa98c960672ec64dbbc56080aab86a4f589c9b6e3e04a3d24af4 |
|
MD5 | a2b6a03f7f81a91e4e3fd3c017cdcf07 |
|
BLAKE2b-256 | f0c8ab369d1c892189268e4ace4aee71485fef383efe688cac4bc6bf9033b717 |