DynamoDB is an Amazon key-value NoSQL database product. It has all the features you would expect for a cloud hosted database, but is designed as a cache and hence has very low response times. There is documentation at Fast NoSQL Key-Value Database – Amazon DynamoDB – Amazon Web Services and also Amazon DynamoDB - Wikipedia.
One thing to note is that the default "time-to-live" is 24 hours, this can be changed by adding an extra attribute to the entity, you can name this whatever you want but it needs to match the table config from when the table was created. It is worth noting that DynamoDB takes a "lazy delete" approach, in other words it could take up to 48 hours to delete something. It is important to read the documentation at Expiring Items By Using DynamoDB Time to Live (TTL) - Amazon DynamoDB on all of this.
If you want to run DynamoDB locally for testing or for ease of access when developing then running it in Docker is an excellent option, you probably want a command like this
docker run --name mydynamo --publish 8000:8000 --detach amazon/dynamodb-local
This will start the latest DynamoDB image published by Amazon on Docker Hub, publishing port 8000 but detaching from the running image and calling the container "mydynamo" this then allows you to use docker stop mydynamo
and docker start mydynamo
to manage it from the command line.
I have found that I have needed to do this in two steps, firstly to create the table and then secondly to configure the "time to live" attribute. The create table itself is straightforward, as follows:
aws dynamodb create-table --table-name my_new_table --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --endpoint-url http://localhost:8000
This assumes you want a table called "my_new_table" and that it has an attribute called "id", of type "string", that you wish to have an index on it. The last part for "--endpoint-url" is handy if you are testing locally on DynamoDB running in Docker, otherwise you can leave this off for a hosted database.
Next, we need to define the TTL (Time to Live) part:
aws dynamodb update-time-to-live --table-name my_new_table --time-to-live-specification "Enabled=true, AttributeName=TimeToLive" --endpoint-url http://localhost:8000
This now means the table "my_new_table" needs two attributes, an "id" which is a string or text and another called "TimeToLive" which contains the "epoch seconds" value of when the item should expire, however, note the comments above on "lazy delete". See Enabling Time to Live (TTL) - Amazon DynamoDB for the command's documentation.
It is quite easy to list the tables in a DynamoDB database, you just need the following command:
aws dynamodb list-tables --output=table --endpoint-url http://localhost:8000
The documentation for this is available at list-tables — AWS CLI 2.7.33 Command Reference.
If you need more details on a specific table then see describe-table — AWS CLI 2.7.33 Command Reference but also note there is a separate command called "describe-time-to-live" if you need to view those settings.