A simple application server that prints a message at a given time in the future
- Setting notifications on the redis server: CONFIG SET notify-keyspace-events Ex
- Subscribing to expire events: PSUBSCRIBE 'keyevent@0:expired'
- For each echo message a unique uuid 'x' is generated as the key while the message is the value.
- Each uuid is backed by 'opaque:x' which is a reference to the same message without expiration.
- When an expire event is triggered, it receives as payload the key expired, to get the message an opaque key is generated to get the message, which is deleted after.
- In case the server was down when a message should have been printed, While the server is up again it checks to see if there exists and opaque:* message and echo them and delete them.
- The exp time is calculated by substracting the (future time - current time) in seconds
$ npm install
# development
$ npm run start:development
# docker-compose
$ docker-compose build
$ docker-compose up
Open your browser and navigate to http://localhost:3000/redis-master/api/swagger
{
"time": 1572197700000,
"message": "Hello"
}
time to time in milliseconds converter: https://currentmillis.com