This example connects to a Redis®* service from
These are the placeholders you will need to replace in the code sample:
URL for Redis connection, from the service overview page
For this example you will need:
redis-cliclient installed. You can install this as part of the Redis server installation or as standalone client.
Execute the following from a terminal window:
redis-cli -u REDIS_URI
This code connects to the Redis®* database.
To check the connection is working, execute the following code:
The command returns all the Redis parameters:
# Server redis_version:6.2.3 redis_git_sha1:c708fc4f redis_git_dirty:1 redis_build_id:eca3e7fbe7ce45c7 redis_mode:standalone ...
To set a key, execute the following command:
SET mykey mykeyvalue123
The command should output a confirmation
To retrieve the key value, execute the following command:
The result is the value of the key, in the above example