Skip to content

Feature/add rest redis cache#88

Open
DanielDango wants to merge 10 commits into
ardoco:feature/add-cache-configurationsfrom
DanielDango:feature/add-rest-redis-cache
Open

Feature/add rest redis cache#88
DanielDango wants to merge 10 commits into
ardoco:feature/add-cache-configurationsfrom
DanielDango:feature/add-rest-redis-cache

Conversation

@DanielDango

Copy link
Copy Markdown
Collaborator

Addresses #59

Adds a rest-redis-based cache to LiSSA.
This PR establishes a Unified Redis Client Interface to bundle access via the Java Redis Client "Jedis" (RedisCache) and the new REST Redis client.

@DanielDango DanielDango requested a review from dfuchss as a code owner June 17, 2026 12:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a REST-Redis-based caching option to LiSSA by introducing a unified Redis client abstraction and wiring a new REST_REDIS cache type into the existing cache factory/hierarchy.

Changes:

  • Introduce UnifiedRedisClient plus adapters for Jedis (RedisAdapter) and REST-Redis (RestRedisAdapter).
  • Add RestRedisCache and CacheType.REST_REDIS, update cache factory/docs/templates accordingly.
  • Add a Testcontainers-backed integration test for REST-Redis and adjust .env overwrite loading behavior.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/test/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisTest.java New integration test spinning up Redis + REST-Redis server and exercising cache + hierarchy behavior.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/utils/Environment.java Adjust .env override loading to set directory + filename explicitly.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/UnifiedRedisClient.java New minimal interface to abstract Redis operations used by caches.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisCache.java New cache implementation backed by REST-Redis client.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisAdapter.java Adapter exposing REST-Redis client through UnifiedRedisClient.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java Refactor to depend on UnifiedRedisClient and support injected client.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisAdapter.java Adapter exposing Jedis client through UnifiedRedisClient.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheType.java Add REST_REDIS cache type.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheManager.java Minor cleanup in cache hierarchy building loop.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java Extend factory to create RestRedisCache for REST_REDIS.
pom.xml Add rest-redis and Testcontainers dependencies.
env-template Document REST_REDIS as a valid cache hierarchy entry.
docs/caching.md Document REST-Redis cache option + related env vars.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/utils/Environment.java
Comment thread pom.xml Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheType.java
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java Outdated
Comment on lines +97 to +101
if (serverThread != null) {
serverThread.interrupt();
serverThread.join(5000);
}
}
@sonarqubecloud

sonarqubecloud Bot commented Jun 23, 2026

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
0 New issues
1 Accepted issue

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Comment thread docs/caching.md
- [`RedisCache`](../src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java): Redis-based cache implementation
- Uses Redis for high-performance caching
- Supports both string and object serialization
- [`RestRedisCache`](../src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisCache.java): REST-based Redis cache implementation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably explain the configuration somewhere here

@dfuchss dfuchss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the copilot comments once more :)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 12 comments.

Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java
Comment on lines +16 to +28
public class RestRedisCache<K extends CacheKey> extends RedisCache<K> {

/**
* Creates a new Rest Redis cache instance.
* This constructor will throw an exception if Rest Redis is unavailable.
*
* @param cacheParameter The cache parameter configuration
* @param mapper The ObjectMapper for JSON operations
* @throws IllegalArgumentException If Redis connection cannot be established
*/
RestRedisCache(CacheParameter<K> cacheParameter, ObjectMapper mapper) {
super(cacheParameter, mapper, createRedisConnection());
}
Comment on lines +9 to +22
* Adapter class that wraps a Jedis client to conform to the UnifiedRedisClient interface.
*/
public class RedisAdapter implements UnifiedRedisClient {

private final UnifiedJedis jedis;

/**
* Creates a new RedisAdapter instance with the given Jedis client.
*
* @param jedis The Jedis client to wrap
*/
RedisAdapter(UnifiedJedis jedis) {
this.jedis = Objects.requireNonNull(jedis);
}
Comment on lines +13 to +27
* @see UnifiedRedisClient
*/
public class RestRedisAdapter implements UnifiedRedisClient {

/** The underlying REST-based Redis client to which all calls are delegated. */
private final Client restRedisClient;

/**
* Constructs a new {@code RestRedisAdapter} wrapping the given client.
*
* @param restRedisClient the REST Redis client to delegate to. Must not be {@code null}
*/
RestRedisAdapter(Client restRedisClient) {
this.restRedisClient = Objects.requireNonNull(restRedisClient);
}
Comment on lines 35 to +44
@@ -41,12 +40,20 @@ class RedisCache<K extends CacheKey> implements Cache<K> {
* @throws IllegalArgumentException If Redis connection cannot be established
*/
RedisCache(CacheParameter<K> cacheParameter, ObjectMapper mapper) {
this(cacheParameter, mapper, createRedisConnection());
}
Comment on lines +92 to +101
@AfterAll
static void stopServer() throws InterruptedException {
if (client != null) {
client.close();
}
if (serverThread != null) {
serverThread.interrupt();
serverThread.join(5000);
}
}
Comment on lines +10 to +18
public interface UnifiedRedisClient {

/**
* Sends a {@code PING} command to the Redis server.
*
* @return {@code true} if the server responds successfully, {@code false} otherwise.
*/
boolean ping();

Comment on lines +39 to +44
String restRedisUri = "http://localhost:8080";
String restRedisUriEnv = Environment.getenv("REST_REDIS_URI");
if (restRedisUriEnv != null) {
restRedisUri = restRedisUriEnv;
}
String restRedisUsername = Environment.getenv("REST_REDIS_USERNAME");
Comment on lines 75 to +79
String redisUrl = "redis://localhost:6379";
if (Environment.getenv("REDIS_URL") != null) {
redisUrl = Environment.getenv("REDIS_URL");
}
jedis = RedisClient.create(redisUrl);
RedisAdapter redis = new RedisAdapter(RedisClient.create(redisUrl));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants