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 Stack (local preferred, Docker is a good option - see instructions below)
- Optional: Docker
- Optional but recommended: RedisInsight to visualize the data in Redis. This is a graphical alternative to the
redis-cli
command
We've provided a Docker Compose file as part of this repo, so to start Redis Stack, use the following command:
docker-compose up -d
This will start a Redis Stack container with Redis exposed on localhost port 6379 with no password. 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
RedisInsight is a graphical tool for viewing data in Redis and managing Redis server instances. You don't need to install it to be successful with this course, but we recommend it as a good way of viewing data stored in Redis.
To use RedisInsight, you'll need to download it then point it at your Redis instance.
If you're using the Docker Compose file provided with this course to run Redis Stack, you can optionally choose to access a web-based version of Redis Stack at http://localhost:8001
whenever the container is running.
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.