The ln-history platform provides the feature to get live data from multiple nodes.
This is particularly interesting when analyzing how fast and complete gossip messages get propergated through the Bitcoin Lightning Network.
To store this (temporary) data and check for duplicates quickly we use a redis -fork valkey cache.
Why valkey and not redis?
After reading this interesting story about licensing changes made by redis, valkey forked away as a truely free and open source alternative.
It is backend by the e. g. Linux foundation .
Setup
We will start by setting up the directory structure and continue with the docker container
Create directory
From the project root we create the cache
directory with the following command.
ln-history@host :~/ln-history ₿ mkdir cache && cd cache Copy icon
Environment variablesauthentication
Create an .env
file and fill in a securely created password.
VALKEY_PASSWORD = YOUR_SECURLY_GENERATED_PASSWORD
🔐 Important : Never commit .env
files containing credentials to version control.
🐳 Docker container
Create the docker-compose.yml
and paste the following content into it.
services :
valkey :
image : valkey/valkey:8.1
container_name : valkey
ports :
- "6379:6379"
volumes :
- valkey-data:/data
restart : unless-stopped
env_file : .env
command : [ "valkey-server" , "--appendonly" , "yes" , "--requirepass" , "${VALKEY_PASSWORD}" ]
volumes :
valkey-data :
Folder structure
Ultimatly the folder structure should look like this:
cache/
├── .env # Environment variables for the service
└── docker-compose.yml # Docker setup for this service
Run
We start the container by using docker compose up -d
(The flag -d
abbreviates deamon
, meaning background process).
ln-history@host :~/ln-history/database ₿ docker compose up -d Copy icon
Verify
See the logs of the docker container.
ln-history@host :~/ln-history/cache ₿ docker compose logs -f --tail=100 Copy icon valkey | 1:M 09 Aug 2025 12:50:18.043 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo
valkey | 1:M 09 Aug 2025 12:50:18.043 * Valkey version=8.1.3, bits=64, commit=00000000, modified=0, pid=1, just started
valkey | 1:M 09 Aug 2025 12:50:18.043 * Configuration loaded
valkey | 1:M 09 Aug 2025 12:50:18.044 * monotonic clock: POSIX clock_gettime
valkey | 1:M 09 Aug 2025 12:50:18.044 * Running mode=standalone, port=6379.
valkey | 1:M 09 Aug 2025 12:50:18.044 * Server initialized
valkey | 1:M 09 Aug 2025 12:50:18.044 * Reading RDB base file on AOF loading...
valkey | 1:M 09 Aug 2025 12:50:18.044 * Loading RDB produced by Valkey version 8.1.3
valkey | 1:M 09 Aug 2025 12:50:18.044 * RDB age 3 seconds
valkey | 1:M 09 Aug 2025 12:50:18.044 * RDB memory usage when created 321.97 Mb
valkey | 1:M 09 Aug 2025 12:50:18.044 * RDB is base AOF
valkey | 1:M 09 Aug 2025 12:50:34.400 * Done loading RDB, keys loaded: 0, keys expired: 0.
valkey | 1:M 09 Aug 2025 12:50:34.400 * DB loaded from base file appendonly.aof.18.base.rdb: 16.355 seconds
valkey | 1:M 09 Aug 2025 12:50:36.545 * DB loaded from incr file appendonly.aof.18.incr.aof: 2.145 seconds
valkey | 1:M 09 Aug 2025 12:50:36.545 * DB loaded from append only file: 18.501 seconds
valkey | 1:M 09 Aug 2025 12:50:36.545 * Opening AOF incr file appendonly.aof.18.incr.aof on server start
valkey | 1:M 09 Aug 2025 12:50:36.545 * Ready to accept connections tcp