Created
November 21, 2022 12:16
-
-
Save tzach/b1369035b075ae62e459064a6ab51dda to your computer and use it in GitHub Desktop.
Demo Scylla Alternator TTL with Docker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Start Scylla | |
docker run --name some-scylla -d scylladb/scylla:5.1.0-rc4 --alternator-port 8000 --alternator-write-isolation=always | |
## Download config | |
docker cp some-scylla:/etc/scylla/scylla.yaml . | |
## Config updates | |
# Uncomment to enable experimental features | |
experimental_features: | |
# - udf | |
# - alternator-streams | |
- alternator-ttl | |
# - raft | |
alternator_ttl_period_in_seconds: 15 | |
## Upload new config | |
docker cp ./scylla.yaml some-scylla:/etc/scylla/scylla.yaml | |
## Restart Scylla to load the new config | |
docker exec -it some-scylla supervisorctl restart scylla | |
## Create table | |
aws --endpoint-url 'http://172.17.0.2:8000' dynamodb create-table --table-name MusicCollection --attribute-definitions AttributeName=Artist,AttributeType=S AttributeName=SongTitle,AttributeType=S --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 | |
## Set TTL | |
aws --endpoint-url 'http://172.17.0.2:8000' dynamodb update-time-to-live --table-name MusicCollection --time-to-live-specification "Enabled=true, AttributeName=ttl" | |
## Put an item with TTL of now() + 30s | |
aws --endpoint-url 'http://172.17.0.2:8000' dynamodb put-item \ | |
--table-name MusicCollection \ | |
--item \ | |
'{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": "Call Me Today"}, "AlbumTitle": {"S": "Somewhat Famous"}, "Awards": {"N": "1"}, "ttl": {"N": "'$(($(date +%s)+30))'"}}' | |
## Scan the table (repeat till value is gone) | |
aws --endpoint-url 'http://172.17.0.2:8000' dynamodb scan --table-name MusicCollection |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment