Skip to content

Commit 9305665

Browse files
committed
Initial commit
1 parent 7888202 commit 9305665

File tree

136 files changed

+22026
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+22026
-1
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.classpath
2+
.project
3+
.settings
4+
target
5+
*.iml
6+
.idea
7+
.DS_Store
8+
redisdata/

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Redis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+127-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,127 @@
1-
# redis-java
1+
# RediSolar for Java
2+
3+
Introduction
4+
---
5+
6+
![Screenshot](screenshot.png)
7+
8+
This is the sample application codebase for RU102J, [Redis for Java Developers](https://university.redis.com/courses/ru102j/) at [Redis University](https://university.redis.com).
9+
10+
Solutions to the course programming challenges can be found on the `solutions` branch.
11+
12+
Prerequisites
13+
---
14+
15+
In order to start and run this application, you will need:
16+
17+
* Java 8 JDK or higher
18+
* [Maven](https://maven.apache.org/)
19+
* Access to a local or remote installation of [Redis Stack](https://redis.io/docs/stack/get-started/install/) (local preferred, Docker is a good option - see instructions below)
20+
* Optional: [Docker](https://www.docker.com/get-started/)
21+
* Optional but recommended: [RedisInsight](https://redis.com/redis-enterprise/redis-insight/) to visualize the data in Redis. This is a graphical alternative to the `redis-cli` command
22+
23+
Running Redis Stack with Docker
24+
---
25+
26+
We've provided a Docker Compose file as part of this repo, so to start Redis Stack, use the following command:
27+
28+
```bash
29+
docker-compose up -d
30+
```
31+
32+
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:
33+
34+
```
35+
Creating network "ru102j_default" with the default driver
36+
Creating redis_ru102j ... done
37+
```
38+
39+
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:
40+
41+
```bash
42+
docker exec -it redis_ru102j redis-cli
43+
```
44+
45+
When you see this prompt:
46+
47+
```
48+
127.0.0.1:6379>
49+
```
50+
51+
you are connected to Redis. Type `quit` to exit the Redis CLI.
52+
53+
When you are finished working with Redis, shut down the server like so:
54+
55+
```bash
56+
docker-compose down
57+
```
58+
59+
Redis saves your data in an append only file in the `redisdata` folder, and will re-load it next time you start the container.
60+
61+
How to Start the RediSolar Application
62+
---
63+
64+
### When using Redis on localhost, port 6379 with no password:
65+
66+
1. Run `mvn package` to build your application.
67+
2. Load the sample data: `java -jar target/redisolar-1.0.jar load`. If you want to erase everything in Redis before loading the data, use `java -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.
68+
3. Start the application with `java -jar target/redisolar-1.0.jar server config.yml`
69+
4. To check that your application is running enter url `http://localhost:8081`, substituting `localhost` for the hostname that you're running the application on if necessary.
70+
71+
### When using Redis on another host, port or with a password:
72+
73+
1. Edit `config.yml`, setting the values for your Redis host, port and password if needed.
74+
2. Edit `src/test/java/com/redislabs/university/RU102J/HostPort.java`, setting the values for your Redis host, port, and password if needed.
75+
3. Run `mvn package` to build your application.
76+
4. Load the sample data with `java -jar target/redisolar-1.0.jar load --host <hostname> --port <port> --password <password>`.
77+
5. Start application with `java -jar target/redisolar-1.0.jar server config.yml`.
78+
6. To check that your application is running enter url `http://localhost:8081`, substituting `localhost` for the hostname that you're running the application on if necessary.
79+
80+
Tests
81+
---
82+
83+
To run all tests:
84+
85+
```
86+
mvn test
87+
```
88+
89+
To run a specific test:
90+
91+
```
92+
mvn test -Dtest=JedisBasicsTest
93+
```
94+
95+
Building
96+
---
97+
98+
To rebuild the application:
99+
100+
```
101+
mvn package
102+
```
103+
104+
To rebuild the application without running the tests:
105+
106+
```
107+
mvn package -DskipTests
108+
```
109+
110+
Optional (but Recommended): RedisInsight
111+
---
112+
113+
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.
114+
115+
To use RedisInsight, you'll need to [download it](https://redis.io/docs/ui/insight/) then point it at your Redis instance.
116+
117+
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.
118+
119+
Need Help / Join our Community
120+
---
121+
122+
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](https://discord.gg/jucCB8h).
123+
124+
Subscribe to our YouTube Channel / Follow us on Twitch
125+
---
126+
127+
We'd love for you to [check out our YouTube channel](https://youtube.com/redisinc), and subscribe if you want to see more Redis videos! We also stream regularly on our [Twitch.tv channel](https://www.twitch.tv/redisinc) - follow us to be notified when we're live or check out our [streaming schedule](https://developer.redis.com/redis-live).

config.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
logging:
2+
level: INFO
3+
loggers:
4+
com.redislabs.university: DEBUG
5+
defaultName: "RediSolar"
6+
redis:
7+
host: localhost
8+
port: 6379
9+
password:
10+
server:
11+
rootPath: /api
12+
applicationConnectors:
13+
- type: http
14+
port: 8081
15+
adminConnectors:
16+
- type: http
17+
port: 8084
18+

docker-compose.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: "3.9"
2+
services:
3+
redis:
4+
container_name: redis_ru102j
5+
image: "redis/redis-stack:latest"
6+
ports:
7+
- "6379:6379"
8+
- "8001:8001"
9+
volumes:
10+
- ./redisdata:/data
11+
environment:
12+
- REDIS_ARGS=--appendonly yes --save ""
13+
deploy:
14+
replicas: 1
15+
restart_policy:
16+
condition: on-failure

0 commit comments

Comments
 (0)