Name | aiocache-dynamodb JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | AioCache DynamoDB Backend using Aiobotocore |
upload_time | 2025-04-18 23:59:07 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT License
Copyright (c) 2025 Jesse Constante
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
aiocache
backend
aws
dynamodb
aiobotocore
cache
asyncio
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# aiocache-dynamodb
[](https://pypi.org/project/aiocache-dynamodb/)
[](https://pypi.org/project/aiocache-dynamodb/)
[](https://github.com/astral-sh/ruff)
[](./coverage-badge.svg)
[](https://github.com/pre-commit/pre-commit)
`aiocache-dynamodb` is an asynchronous cache backend for DynamoDB, built on top of [`aiobotocore`](https://github.com/aio-libs/aiobotocore) and [`aiocache`](https://github.com/aio-libs/aiocache). It provides a fully asynchronous interface for caching data using DynamoDB, allowing for efficient and scalable caching solutions in Python applications.
For more information on aiocache:
- [aiocache documentation](https://aiocache.readthedocs.io/en/latest/)
For more information on aiobotocore:
- [aiobotocore documentation](https://aiobotocore.readthedocs.io/en/latest/)
## Features
- Fully asynchronous operations using `aiobotocore`.
- TTL support for expiring cache items (even though DynamoDB only deletes items within 48hr of expiration, we double-check).
- Batch operations for efficient multi-key handling.
- Customizable key, value, and TTL column names.
- (Planned) S3 integration for large object storage.
---
## Installation
Install the package using pip:
```bash
pip install aiocache-dynamodb
```
## Usage
```python
import asyncio
from aiocache_dynamodb import DynamoDBCache
async def main():
cache = DynamoDBCache(
table_name="my-cache-table",
endpoint_url="http://localhost:4566", # For local development
aws_access_key_id="your-access-key",
aws_secret_access_key="your-secret-key",
region_name="us-east-1",
)
# Set a value with a TTL of 60 seconds
await cache.set("my_key", "my_value", ttl=60)
# Get the value
value = await cache.get("my_key")
print(value) # Output: my_value
# Delete the value
await cache.delete("my_key")
# Check if the key exists
exists = await cache.exists("my_key")
print(exists) # Output: False
# Close the cache
await cache.close()
asyncio.run(main())
```
## Configuration
The `DynamoDBCache` class supports the following parameters:
- `serializer`: Serializer to use for serializing and deserializing values (default: `aiocache.serializers.JsonSerializer`).
- `plugins`: List of plugins to use (default: `[]`).
- `namespace`: Namespace to use for the cache (default: `""`).
- `timeout`: Timeout for cache operations (default: `5`).
- `table_name`: Name of the DynamoDB table to use for caching.
- `endpoint_url`: Endpoint URL for DynamoDB (useful for LocalStack).
- `region_name`: AWS region (default: `"us-east-1"`).
- `aws_access_key_id`: AWS access key ID.
- `aws_secret_access_key`: AWS secret access key.
- `key_column`: Column name for the cache key (default: `"cache_key"`).
- `value_column`: Column name for the cache value (default: `"cache_value"`).
- `ttl_column`: Column name for the TTL (default: `"ttl"`).
# Local Development:
We use make to handle the commands for the project, you can see the available commands by running this in the root directory:
```bash
make
```
## Setup
To setup the project, you can run the following commands:
```bash
make install
```
This will install the required dependencies for the project using pip.
## Linting
We use pre-commit to do linting locally, this will be included in the dev dependencies.
We use ruff for linting and formatting, and pyright for static type checking.
To install the pre-commit hooks, you can run the following command:
```bash
pre-commit install
```
If you for some reason hate pre-commit, you can run the following command to lint the code:
```bash
make check
```
## Testing
To run tests, you can use the following command:
```bash
make test
```
In the background this will setup localstack to replicate the AWS services, and run the tests.
It will also generate the coverage badge.
Raw data
{
"_id": null,
"home_page": null,
"name": "aiocache-dynamodb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "aiocache, backend, aws, dynamodb, aiobotocore, cache, asyncio",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/1b/2c/17985e624e38101b1b98ed85cf34b7cc7854e385247a20978c7319abe4f1/aiocache_dynamodb-0.0.3.tar.gz",
"platform": null,
"description": "# aiocache-dynamodb\n\n[](https://pypi.org/project/aiocache-dynamodb/)\n[](https://pypi.org/project/aiocache-dynamodb/)\n[](https://github.com/astral-sh/ruff)\n[](./coverage-badge.svg)\n[](https://github.com/pre-commit/pre-commit)\n\n`aiocache-dynamodb` is an asynchronous cache backend for DynamoDB, built on top of [`aiobotocore`](https://github.com/aio-libs/aiobotocore) and [`aiocache`](https://github.com/aio-libs/aiocache). It provides a fully asynchronous interface for caching data using DynamoDB, allowing for efficient and scalable caching solutions in Python applications.\n\nFor more information on aiocache:\n- [aiocache documentation](https://aiocache.readthedocs.io/en/latest/)\n\nFor more information on aiobotocore:\n- [aiobotocore documentation](https://aiobotocore.readthedocs.io/en/latest/)\n\n## Features\n\n- Fully asynchronous operations using `aiobotocore`.\n- TTL support for expiring cache items (even though DynamoDB only deletes items within 48hr of expiration, we double-check).\n- Batch operations for efficient multi-key handling.\n- Customizable key, value, and TTL column names.\n- (Planned) S3 integration for large object storage.\n---\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install aiocache-dynamodb\n```\n\n## Usage\n```python\nimport asyncio\nfrom aiocache_dynamodb import DynamoDBCache\n\nasync def main():\n cache = DynamoDBCache(\n table_name=\"my-cache-table\",\n endpoint_url=\"http://localhost:4566\", # For local development\n aws_access_key_id=\"your-access-key\",\n aws_secret_access_key=\"your-secret-key\",\n region_name=\"us-east-1\",\n )\n\n # Set a value with a TTL of 60 seconds\n await cache.set(\"my_key\", \"my_value\", ttl=60)\n\n # Get the value\n value = await cache.get(\"my_key\")\n print(value) # Output: my_value\n\n # Delete the value\n await cache.delete(\"my_key\")\n\n # Check if the key exists\n exists = await cache.exists(\"my_key\")\n print(exists) # Output: False\n\n # Close the cache\n await cache.close()\n\nasyncio.run(main())\n```\n\n## Configuration\nThe `DynamoDBCache` class supports the following parameters:\n\n- `serializer`: Serializer to use for serializing and deserializing values (default: `aiocache.serializers.JsonSerializer`).\n- `plugins`: List of plugins to use (default: `[]`).\n- `namespace`: Namespace to use for the cache (default: `\"\"`).\n- `timeout`: Timeout for cache operations (default: `5`).\n- `table_name`: Name of the DynamoDB table to use for caching.\n- `endpoint_url`: Endpoint URL for DynamoDB (useful for LocalStack).\n- `region_name`: AWS region (default: `\"us-east-1\"`).\n- `aws_access_key_id`: AWS access key ID.\n- `aws_secret_access_key`: AWS secret access key.\n- `key_column`: Column name for the cache key (default: `\"cache_key\"`).\n- `value_column`: Column name for the cache value (default: `\"cache_value\"`).\n- `ttl_column`: Column name for the TTL (default: `\"ttl\"`).\n\n\n# Local Development:\nWe use make to handle the commands for the project, you can see the available commands by running this in the root directory:\n```bash\nmake\n```\n\n## Setup\nTo setup the project, you can run the following commands:\n```bash\nmake install\n```\nThis will install the required dependencies for the project using pip.\n\n## Linting\nWe use pre-commit to do linting locally, this will be included in the dev dependencies.\nWe use ruff for linting and formatting, and pyright for static type checking.\nTo install the pre-commit hooks, you can run the following command:\n```bash\npre-commit install\n```\nIf you for some reason hate pre-commit, you can run the following command to lint the code:\n```bash\nmake check\n```\n\n## Testing\nTo run tests, you can use the following command:\n```bash\nmake test\n```\nIn the background this will setup localstack to replicate the AWS services, and run the tests.\nIt will also generate the coverage badge.\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Jesse Constante\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "AioCache DynamoDB Backend using Aiobotocore",
"version": "0.0.3",
"project_urls": {
"source": "https://github.com/vonsteer/aiocache-dynamodb"
},
"split_keywords": [
"aiocache",
" backend",
" aws",
" dynamodb",
" aiobotocore",
" cache",
" asyncio"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "f3daee600cbae0ba02bffb51361cbc12dcab496cf369c5b019c09d2b594374b2",
"md5": "664d36a76965a3a0d64458c206faadf0",
"sha256": "3963dc599c5ead8caad5a2d618ccd04e9293d9e764a37f3b167a7f907c6b53af"
},
"downloads": -1,
"filename": "aiocache_dynamodb-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "664d36a76965a3a0d64458c206faadf0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 11329,
"upload_time": "2025-04-18T23:59:05",
"upload_time_iso_8601": "2025-04-18T23:59:05.432295Z",
"url": "https://files.pythonhosted.org/packages/f3/da/ee600cbae0ba02bffb51361cbc12dcab496cf369c5b019c09d2b594374b2/aiocache_dynamodb-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "1b2c17985e624e38101b1b98ed85cf34b7cc7854e385247a20978c7319abe4f1",
"md5": "7c10a25636836b9df0530756c65eb457",
"sha256": "2d39ad330a9874fb2b7dff57e6c616a080b9a0e08970a18eb2f24852e5b5361e"
},
"downloads": -1,
"filename": "aiocache_dynamodb-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "7c10a25636836b9df0530756c65eb457",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 15598,
"upload_time": "2025-04-18T23:59:07",
"upload_time_iso_8601": "2025-04-18T23:59:07.046139Z",
"url": "https://files.pythonhosted.org/packages/1b/2c/17985e624e38101b1b98ed85cf34b7cc7854e385247a20978c7319abe4f1/aiocache_dynamodb-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-04-18 23:59:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "vonsteer",
"github_project": "aiocache-dynamodb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aiocache-dynamodb"
}