A simple YAML-based cache for Python
Project description
yamlsync
Yaml Sync is a very lightweight YAML-based cache for when you want to preserve the state of something on disk in a human readable way.
Installation
To install Yaml Sync, simply run:
pip install yaml-cache
Example usage
Here's a quick example of how to use Yaml Sync:
from yaml_sync import YamlCache
# Create a cache that reads and writes to the specified file
cache = YamlCache('cache.yaml', mode='rw')
# Save a key to the cache and write to disk
cache['hello'] = 'world'
# Check if a key is in the cache
assert 'hello' in cache
# Retrieve a key from the cache
variable = cache['hello']
# Save a list to the cache
cache['list_example'] = [1, 2, 3]
The resulting yaml will be:
hello: world
list_example:
0: 1
1: 2
2: 3
You can pass number_lists=True
at init to save any lists as a numbered dictionary. Since the goal of Yaml Sync is a human-readable file, the numbering may be desired in some cases.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yaml-sync-0.1.1.tar.gz
(3.3 kB
view hashes)
Built Distribution
Close
Hashes for yaml_sync-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39a29c56c60ba2b6ed1a3d3ea3b99b7c14b51faf601a6b57cd3a55d1a421dc93 |
|
MD5 | 5a343bb2a11569d57f6ed57ac427b4ce |
|
BLAKE2b-256 | fc5d705dd8ff0836f1cc0ffc7cb701b0a0c84a48bc5fc95e841852c2cd6563e7 |