This is the sample application codebase for RU102J, Redis for Java Developers at Redis University.
Solutions to the course programming challenges can be found on the solutions
branch.
In order to start and run this application, you will need:
- Java 8 JDK or higher
- Maven
- Access to a local or remote installation of Redis version 5 or newer (local preferred, Docker is a good option - see instructions below)
- If you want to try the RedisTimeSeries exercises, you'll need to make sure that your Redis installation also has the RedisTimeSeries Module installed (or use the provided Docker Compose file which gives you Redis with RedisTimeSeries)
- Optional: Docker
- Optional but recommended: RedisInsight to visualize the data in Redis. This is a graphical alternative to the
redis-cli
command
If you're using Windows, check out the following resources for help with running Redis:
- Redis Blog - Running Redis on Windows 10
- Microsoft - Windows Subsystem for Linux Installation Guide for Windows 10
We've provided a Docker Compose file as part of this repo, so to start Redis with the RedisTimeSeries module installed, use the following command:
docker-compose up -d
This will start a Redis with RedisTimeSeries container on localhost port 6379 with no password and you should see output similar to the following:
Creating network "ru102j_default" with the default driver
Creating redis_ru102j ... done
Connect to Redis using either RedisInsight, or the redis-cli
command. When using redis-cli
you can invoke it from the Docker container like this:
docker exec -it redis_ru102j redis-cli
When you see this prompt:
127.0.0.1:6379>
you are connected to Redis. Type quit
to exit the Redis CLI.
When you are finished working with Redis, shut down the server like so:
docker-compose down
Redis saves your data in an append only file in the redisdata
folder, and will re-load it next time you start the container.
- Run
mvn package
to build your application. - Load the sample data:
java -jar target/redisolar-1.0.jar load
. If you want to erase everything in Redis before loading the data, usejava -jar target/redisolar-1.0.jar load --flush true
, but be aware that this will delete ALL keys in your Redis database. Note that loading the data may take a few minutes. - Start the application with
java -jar target/redisolar-1.0.jar server config.yml
- To check that your application is running enter url
http://localhost:8081
, substitutinglocalhost
for the hostname that you're running the application on if necessary.
- Edit
config.yml
, setting the values for your Redis host, port and password if needed. - Edit
src/test/java/com/redislabs/university/RU102J/HostPort.java
, setting the values for your Redis host, port, and password if needed. - Run
mvn package
to build your application. - Load the sample data with
java -jar target/redisolar-1.0.jar load --host <hostname> --port <port> --password <password>
. - Start application with
java -jar target/redisolar-1.0.jar server config.yml
. - To check that your application is running enter url
http://localhost:8081
, substitutinglocalhost
for the hostname that you're running the application on if necessary.
To run all tests:
mvn test
To run a specific test:
mvn test -Dtest=JedisBasicsTest
To rebuild the application:
mvn package
To rebuild the application without running the tests:
mvn package -DskipTests
If you need help with the course or want to chat to your fellow students and the wider Redis community, please join us on our Discord server.
We'd love for you to check out our YouTube channel, and subscribe if you want to see more Redis videos! We also stream regularly on our Twitch.tv channel - follow us to be notified when we're live or check out our streaming schedule.