Feature/add rest redis cache#88
Open
DanielDango wants to merge 10 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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
UnifiedRedisClientplus adapters for Jedis (RedisAdapter) and REST-Redis (RestRedisAdapter). - Add
RestRedisCacheandCacheType.REST_REDIS, update cache factory/docs/templates accordingly. - Add a Testcontainers-backed integration test for REST-Redis and adjust
.envoverwrite 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 on lines
+97
to
+101
| if (serverThread != null) { | ||
| serverThread.interrupt(); | ||
| serverThread.join(5000); | ||
| } | ||
| } |
|
dfuchss
reviewed
Jun 24, 2026
| - [`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 |
Member
There was a problem hiding this comment.
Probably explain the configuration somewhere here
dfuchss
approved these changes
Jun 24, 2026
dfuchss
left a comment
Member
There was a problem hiding this comment.
Check the copilot comments once more :)
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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.