# RedisEncoderDecoder Utility Module
A utility module for encoding and decoding dictionaries with JSON values for use with Redis.
## Overview
The `RedisEncoderDecoder` module provides a convenient way to encode and decode dictionaries with JSON values. This is particularly useful when working with Redis, where values are often stored as strings. By using JSON serialization, complex data types such as dictionaries and lists can be easily stored and retrieved from Redis.
## Features
- **Encode dictionaries to JSON strings**: Convert dictionary values to JSON formatted strings for easy storage in Redis.
- **Decode JSON strings to original data types**: Convert JSON formatted strings back to their original data types.
- **Error Handling**: Gracefully handle non-serializable values and invalid JSON strings with proper logging.
## Installation
To install the module, use Poetry:
```bash
poetry add redis-encoder-decoder
```
## Usage
### Encoding a Dictionary
```python
from redis_encoder_decoder import RedisEncoderDecoder
dictionary = {'key1': {'nested_key': 42}, 'key2': 'value', 'key3': [1, 2, 3]}
encoded_dict = RedisEncoderDecoder.encoder(dictionary)
print(encoded_dict)
# Output: {'key1': '{"nested_key": 42}', 'key2': 'value', 'key3': '[1, 2, 3]'}
```
### Decoding a Dictionary
```python
from redis_encoder_decoder import RedisEncoderDecoder
encoded_dict = {'key1': '{"nested_key": 42}', 'key2': 'value', 'key3': '[1, 2, 3]'}
decoded_dict = RedisEncoderDecoder.decoder(encoded_dict)
print(decoded_dict)
# Output: {'key1': {'nested_key': 42}, 'key2': 'value', 'key3': [1, 2, 3]}
```
## Benefits
### JSON Serialization for Redis
Redis is a powerful in-memory data structure store commonly used as a database, cache, and message broker. However, it stores all values as strings, which can be limiting when dealing with complex data types. The `RedisEncoderDecoder` module addresses this limitation by serializing Python dictionaries and other complex data types into JSON strings, making it easy to store and retrieve these types from Redis.
### Error Handling
The module includes robust error handling to manage cases where values are not JSON serializable or JSON strings are invalid. It logs warnings and retains original values, ensuring that data integrity is maintained even when issues arise.
## Contributing
We welcome contributions to improve the `RedisEncoderDecoder` module! Here are some ways you can contribute:
1. **Report Bugs**: If you encounter any issues, please report them using the GitHub issue tracker.
2. **Submit Pull Requests**: If you have an improvement or a fix, submit a pull request. Please ensure your code follows the existing coding style and passes all tests.
3. **Write Tests**: Help us improve the module's robustness by writing tests. Make sure your tests cover edge cases and different scenarios.
4. **Improve Documentation**: If you find any part of the documentation unclear or incomplete, feel free to suggest changes or add more details.
### Steps to Contribute
1. **Fork the Repository**: Create a fork of the repository on GitHub.
2. **Clone Your Fork**: Clone your fork to your local machine.
```bash
git clone https://github.com/yourusername/redis-encoder-decoder.git
cd redis-encoder-decoder
```
3. **Create a Branch**: Create a new branch for your feature or bugfix.
```bash
git checkout -b feature-name
```
4. **Install Dependencies**: Use Poetry to install the project dependencies.
```bash
poetry install
```
5. **Make Changes**: Implement your changes.
6. **Run Tests**: Ensure all tests pass.
```bash
poetry run pytest --cov=redis_encoder_decoder tests/
```
7. **Commit and Push**: Commit your changes and push them to your fork.
```bash
git add .
git commit -m "Description of your changes"
git push origin feature-name
```
8. **Submit a Pull Request**: Go to the original repository and submit a pull request.
We appreciate your contributions and are excited to see what you will improve!
## License
This project is licensed under the LGPL v2.1 License - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/carlinix/redis-encoder-decoder",
"name": "redis-encdec",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "redis, encoder, decoder, json, utility",
"author": "Ricardo Carlini",
"author_email": "rcarlini@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/33/1b/2e14c20b3d8a26025b8aa77b982a7973f917d9b2b40ea4aa6c6ca20cc191/redis_encdec-0.1.1.tar.gz",
"platform": null,
"description": "# RedisEncoderDecoder Utility Module\n\nA utility module for encoding and decoding dictionaries with JSON values for use with Redis.\n\n## Overview\n\nThe `RedisEncoderDecoder` module provides a convenient way to encode and decode dictionaries with JSON values. This is particularly useful when working with Redis, where values are often stored as strings. By using JSON serialization, complex data types such as dictionaries and lists can be easily stored and retrieved from Redis.\n\n## Features\n\n- **Encode dictionaries to JSON strings**: Convert dictionary values to JSON formatted strings for easy storage in Redis.\n- **Decode JSON strings to original data types**: Convert JSON formatted strings back to their original data types.\n- **Error Handling**: Gracefully handle non-serializable values and invalid JSON strings with proper logging.\n\n## Installation\n\nTo install the module, use Poetry:\n\n```bash\npoetry add redis-encoder-decoder\n```\n\n## Usage\n\n### Encoding a Dictionary\n\n```python\nfrom redis_encoder_decoder import RedisEncoderDecoder\n\ndictionary = {'key1': {'nested_key': 42}, 'key2': 'value', 'key3': [1, 2, 3]}\nencoded_dict = RedisEncoderDecoder.encoder(dictionary)\nprint(encoded_dict)\n# Output: {'key1': '{\"nested_key\": 42}', 'key2': 'value', 'key3': '[1, 2, 3]'}\n```\n\n### Decoding a Dictionary\n\n```python\nfrom redis_encoder_decoder import RedisEncoderDecoder\n\nencoded_dict = {'key1': '{\"nested_key\": 42}', 'key2': 'value', 'key3': '[1, 2, 3]'}\ndecoded_dict = RedisEncoderDecoder.decoder(encoded_dict)\nprint(decoded_dict)\n# Output: {'key1': {'nested_key': 42}, 'key2': 'value', 'key3': [1, 2, 3]}\n```\n\n## Benefits\n\n### JSON Serialization for Redis\n\nRedis is a powerful in-memory data structure store commonly used as a database, cache, and message broker. However, it stores all values as strings, which can be limiting when dealing with complex data types. The `RedisEncoderDecoder` module addresses this limitation by serializing Python dictionaries and other complex data types into JSON strings, making it easy to store and retrieve these types from Redis.\n\n### Error Handling\n\nThe module includes robust error handling to manage cases where values are not JSON serializable or JSON strings are invalid. It logs warnings and retains original values, ensuring that data integrity is maintained even when issues arise.\n\n## Contributing\n\nWe welcome contributions to improve the `RedisEncoderDecoder` module! Here are some ways you can contribute:\n\n1. **Report Bugs**: If you encounter any issues, please report them using the GitHub issue tracker.\n\n2. **Submit Pull Requests**: If you have an improvement or a fix, submit a pull request. Please ensure your code follows the existing coding style and passes all tests.\n\n3. **Write Tests**: Help us improve the module's robustness by writing tests. Make sure your tests cover edge cases and different scenarios.\n\n4. **Improve Documentation**: If you find any part of the documentation unclear or incomplete, feel free to suggest changes or add more details.\n\n### Steps to Contribute\n\n1. **Fork the Repository**: Create a fork of the repository on GitHub.\n\n2. **Clone Your Fork**: Clone your fork to your local machine.\n\n ```bash\n git clone https://github.com/yourusername/redis-encoder-decoder.git\n cd redis-encoder-decoder\n ```\n\n3. **Create a Branch**: Create a new branch for your feature or bugfix.\n\n ```bash\n git checkout -b feature-name\n ```\n\n4. **Install Dependencies**: Use Poetry to install the project dependencies.\n\n ```bash\n poetry install\n ```\n\n5. **Make Changes**: Implement your changes.\n\n6. **Run Tests**: Ensure all tests pass.\n\n ```bash\n poetry run pytest --cov=redis_encoder_decoder tests/\n ```\n\n7. **Commit and Push**: Commit your changes and push them to your fork.\n\n ```bash\n git add .\n git commit -m \"Description of your changes\"\n git push origin feature-name\n ```\n\n8. **Submit a Pull Request**: Go to the original repository and submit a pull request.\n\nWe appreciate your contributions and are excited to see what you will improve!\n\n## License\n\nThis project is licensed under the LGPL v2.1 License - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "LGPL-2.1",
"summary": "A utility module for encoding and decoding dictionaries with JSON values for use with Redis.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/carlinix/redis-encoder-decoder",
"Repository": "https://github.com/carlinix/redis-encoder-decoder"
},
"split_keywords": [
"redis",
" encoder",
" decoder",
" json",
" utility"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "59c4d76e21f93ade3ee820cd57eb20f8e8a46947348274379e316f181c3f0cc5",
"md5": "0b8f9d8e0112c79c038f4bef773b1c98",
"sha256": "0b61cf131792e9fe50b30450f1fd56dd84ce6ee27dd8e6b1469cea67a3184956"
},
"downloads": -1,
"filename": "redis_encdec-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0b8f9d8e0112c79c038f4bef773b1c98",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 13554,
"upload_time": "2024-07-09T12:11:42",
"upload_time_iso_8601": "2024-07-09T12:11:42.224187Z",
"url": "https://files.pythonhosted.org/packages/59/c4/d76e21f93ade3ee820cd57eb20f8e8a46947348274379e316f181c3f0cc5/redis_encdec-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "331b2e14c20b3d8a26025b8aa77b982a7973f917d9b2b40ea4aa6c6ca20cc191",
"md5": "142d1d39df73c9a3ed69dbd21d000e48",
"sha256": "36520f737de5f26b8a2b9c98b949628b2e32e62a2964b46b88581f5ce63bd643"
},
"downloads": -1,
"filename": "redis_encdec-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "142d1d39df73c9a3ed69dbd21d000e48",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 15563,
"upload_time": "2024-07-09T12:11:44",
"upload_time_iso_8601": "2024-07-09T12:11:44.370813Z",
"url": "https://files.pythonhosted.org/packages/33/1b/2e14c20b3d8a26025b8aa77b982a7973f917d9b2b40ea4aa6c6ca20cc191/redis_encdec-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-09 12:11:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "carlinix",
"github_project": "redis-encoder-decoder",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "redis-encdec"
}