Skip to content

Feature/add rest redis cache#88

Merged
dfuchss merged 48 commits into
ardoco:mainfrom
DanielDango:feature/add-rest-redis-cache
Jul 15, 2026
Merged

Feature/add rest redis cache#88
dfuchss merged 48 commits into
ardoco:mainfrom
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.

 - add new redis cache replacement strategy
…pdate CacheManager to support initialization from ModuleConfiguration
…e/add-cache-configurations

# Conflicts:
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/configuration/EvaluationConfiguration.java
…ature/add-cache-configurations

# Conflicts:
#	src/test/java/edu/kit/kastel/sdq/lissa/ratlr/ArchitectureTest.java
…ions - aside from the local cache dir for replication - from individual environment variables.
…propriate methods to avoid serialization conflicts
…e non-empty list. Also fail fast if configured caches are unavailable

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 thread docs/caching.md

@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.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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 thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisCache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/UnifiedRedisClient.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java
DanielDango and others added 3 commits July 15, 2026 15:16
…d classes and update exception types in RedisCache
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@DanielDango
DanielDango changed the base branch from feature/add-cache-configurations to main July 15, 2026 14:12
dfuchss added 2 commits July 15, 2026 16:14
…tions' into feature/add-rest-redis-cache

# Conflicts:
#	docs/caching.md
# Conflicts:
#	docs/caching.md
#	env-template
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheType.java
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/utils/Environment.java
#	src/test/java/edu/kit/kastel/sdq/lissa/ratlr/ArchitectureTest.java
Copilot AI review requested due to automatic review settings July 15, 2026 14:17
@sonarqubecloud

Copy link
Copy Markdown

@dfuchss
dfuchss merged commit 92830ae into ardoco:main Jul 15, 2026
3 checks passed

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 6 comments.

Comments suppressed due to low confidence (1)

src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java:36

  • UnifiedRedisClient is closeable, but RedisCache never closes the underlying client, and CacheManager only calls flush() on reset/teardown. This can leak connections/sockets over a long-running process or in repeated tests. Consider adding a close lifecycle (e.g., make Cache extend AutoCloseable and have CacheManager close caches on reset/shutdown, and/or add a close() method to RedisCache/HierarchicalCache that delegates to underlying clients).
    private final UnifiedRedisClient redis;

    /**
     * Creates a new Redis cache instance.
     * This constructor will throw an exception if Redis is unavailable.


@Container
private static final GenericContainer<?> REDIS =
new GenericContainer<>(DockerImageName.parse("redis:latest")).withExposedPorts(6379);
Comment on lines +228 to +231
assertTrue(Assertions.assertThrows(
IllegalStateException.class, () -> hierarchicalCacheError.get(testKey, String.class))
.getMessage()
.contains("Cache inconsistency"));
Comment on lines +267 to +270
private static int findFreePort() throws IOException {
try (ServerSocket socket = new ServerSocket(0)) {
return socket.getLocalPort();
}
Comment on lines +29 to +32
@Override
public boolean ping() {
return jedis.ping().equals("PONG");
}
jedis.ping();
if (!redis.ping()) {
redis.close();
throw new IllegalStateException("Could not connect to Redis. Make sure the container is up and running.");
Comment on lines 138 to 142
static <K extends CacheKey> Cache<K> createByType(
CacheType type, CacheParameter<K> parameters, @Nullable String cacheDir, @Nullable ObjectMapper mapper) {
return switch (type) {
case LOCAL -> new LocalCache<>(cacheDir, parameters);
case REDIS -> new RedisCache<>(parameters, mapper);
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