Skip to content
 
 

Repository files navigation

Basic Redis Caching Demo Spring (Java)

This app returns the number of repositories in a given GitHub account. When you first search for an account, the server calls GitHub's API to return the response. This can take 100s of milliseconds. The server then caches this response in Redis for future requests. When you search again, the next response comes directly from a Redis cache instead of calling GitHub. The responses usually take around a millisecond.

Try it out

Deploy to Heorku

Run on Google Cloud (See notes: How to run on Google Cloud)

How to run on Google Cloud

  1. Click the link under "Manage this application at Cloud Console".

1 step

  1. Click "Edit and deploy new revision" button and then choose "Variables & Secrets" as shown below:

2 step

  1. Access the app

3 step


How it works?

1. How the data is stored:

  1. New repos are added:
    SETEX github_username timeout amount_of_repositories
    Example: SETEX redis 3600 14
    more information

2. How the data is accessed:

  1. Get cache (Don't think about cache's timeout):
    GET github_username
    Example: GET redis
    more information

How to run it locally?

Configure Redis, via environment variables (see server/src/main/resources/application.yml):

- REDIS_URL: Redis server url
- REDIS_HOST: Redis server host
- REDIS_PORT: Redis server port
- REDIS_PASSWORD: Redis server password

Run backend

  1. Install JDK 17 or later (on mac: brew install openjdk@17)

  2. From the root directory of the project, run the following commands (the bundled Gradle wrapper downloads the correct Gradle version automatically):

./gradlew server:build
./gradlew server:bootRun
  1. Point your browser to localhost:8080.

Run frontend

Static сontent runs automatically with the backend part. In case you need to run it separately, please see README in the client folder

About

This repo shows a basic caching demo in Java

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages