This is a Redis starter template for Java/Spring:
Copy and edit the .env
file:
Your .env
file should contain the connection string you copied from Redis Cloud.
Your .env.docker
file will look similar to .env
, but should use the appropriate docker internal URLs. Here is an example:
REDIS_URL="redis://redis:6379"
Next, spin up docker containers:
You should have a server running on http://localhost:<port>
where the port is set in your .env
file (default is 8000). You can test the following routes:
GET /api/todos
- Gets all todosGET /api/todos/:id
- Gets a todo by IDGET /api/todos?[name=<name>]&[status=<status>]
- Search for todos by name and/or statusPOST /api/todos
- Create a todo with { "name": "Sample todo" }
PATCH /api/todos/:id
- Update todo by ID with { "status": "todo|in progress|complete" }
DELETE /api/todos/:id
- Delete a todo by IDThere are some tests in the test/java/io/redis/todoapp
directory that can be run with the following command:
These tests setup and teardown on their own. You can modify them if you want to leave data in Redis.
Running locally outside dockerTo run the development server outside of docker, first install:
./mvnw install -Dmaven.test.skip
then run:
Connecting to Redis CloudIf you don't yet have a database setup in Redis Cloud get started here for free.
To connect to a Redis Cloud database, log into the console and find the following:
public endpoint
(looks like redis-#####.c###.us-east-1-#.ec2.redns.redis-cloud.com:#####
)username
(default
is the default username, otherwise find the one you setup)password
(either setup through Data Access Control, or available in the Security
section of the database page.Combine the above values into a connection string and put it in your .env
and .env.docker
accordingly. It should look something like the following:
REDIS_URL="redis://default:<password>@redis-#####.c###.us-west-2-#.ec2.redns.redis-cloud.com:#####"
Run the tests to verify that you are connected properly.
To learn more about Redis, take a look at the following resources:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4