ddbc
Description
Amazon DynamoDB as a cache store.
Requirements
Python2.7
pip
Installation
PyPI
pip install ddbc
Setup
Create IAM Role or User
Policy example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:CreateTable",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:PutItem"
],
"Resource": "arn:aws:dynamodb:<region>:<account-id>:table/<cache-table>"
}
]
}
Create the DynamoDB table for cache
Script Example:
#!/usr/bin/env python
import ddbc.utils
ddbc.utils.create_table(
table_name='cache_table',
region='us-east-1', # optional
read_units=10, # default: 5
write_units=10 # default: 5
)
Usage
import ddbc.cache
import time
cache = ddbc.cache.Client(
table_name='cache_table',
region='us-east-1', # optional
default_ttl=100, # default: -1 (Infinity)
report_error=True # default: False
)
cache['foo'] = 'bar'
print(cache['foo']) # => 'bar'
time.sleep(100)
print(cache['foo']) # => None
cache.set('foo', 'bar', 1000)
time.sleep(100)
print(cache['foo']) # => 'bar'
del cache['foo']
print(cache.get('foo', 'buz')) # => 'buz'
Development
Source hosted at GitHub
Report issues/questions/feature requests on GitHub Issues
Pull requests are very welcome! Make sure your patches are well tested. Ideally create a topic branch for every separate change you make. For example:
Fork the repo
Create your feature branch (git checkout -b my-new-feature)
Commit your changes (git commit -am 'Added some feature')
Push to the branch (git push origin my-new-feature)
Create new Pull Request
License
MIT License (see LICENSE)
Metadata
Release files for ddbc 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ddbc-0.1.0-py2-none-any.whl | Python 2 | none | any | Details |
Release files / ddbc-0.1.0-py2-none-any.whl
| Download URL | ddbc-0.1.0-py2-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
d9c72d78841e551defb1691de0f6b87acbc262ed7f0355fe1ffc92df63107a0c
|
|
BLAKE2b-256 checksum How to use checksums |
158d0bfb758decf7fc62410a6f6b75bb7e3c624912f8c1a6f0bf9f01049a183f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |