Skip to content

feat: implement RestRedisCache and RedisClient for REST-based Redis s…#1

Open
DanielDango wants to merge 1 commit into
feature/add-cache-configurationsfrom
feature/add-rest-cache
Open

feat: implement RestRedisCache and RedisClient for REST-based Redis s…#1
DanielDango wants to merge 1 commit into
feature/add-cache-configurationsfrom
feature/add-rest-cache

Conversation

@DanielDango
Copy link
Copy Markdown
Owner

…torage

Copilot AI review requested due to automatic review settings May 27, 2026 13:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a REST-backed Redis cache path alongside the existing Jedis-backed Redis cache, using a shared Redis client abstraction.

Changes:

  • Introduces UnifiedRedisClient plus Jedis and REST Redis adapters.
  • Adds RestRedisCache and factory support for rest_redis.
  • Adds the org.fuchss:rest-redis dependency and REST Redis integration tests.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/UnifiedRedisClient.java Adds common Redis operation interface.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisAdapter.java Wraps Jedis behind the new interface.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisAdapter.java Wraps REST Redis client behind the new interface.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RedisCache.java Refactors Redis cache to use the abstraction and adds injected-client constructor/exists method.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisCache.java Adds REST Redis cache implementation and environment-based connection setup.
src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java Adds case-insensitive factory selection and rest_redis support.
src/test/java/edu/kit/kastel/sdq/lissa/ratlr/cache/RestRedisIntegrationTest.java Adds integration tests for REST Redis cache behavior.
pom.xml Adds REST Redis client dependency.

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

redisUrl = Environment.getenv("REDIS_URL");
}
jedis = new UnifiedJedis(redisUrl);
jedis = new RedisAdapter(RedisClient.create(redisUrl));
}
yield new RedisCache<>(parameters, mapper);
}
case "rest_redis" -> new RestRedisCache<>(parameters, mapper);
}
case "rest_redis" -> new RestRedisCache<>(parameters, mapper);
default ->
throw new IllegalArgumentException("Unknown cache type: " + type + ". Supported types: local, redis");
Comment on lines +43 to +44
if (!redis.ping()) {
throw new IllegalStateException("Could not connect to redis");
}

public boolean exists(String key) {
return jedis.exists(key);
Comment on lines +27 to +29
@BeforeEach
public void setup() {
restCache = new RestRedisCache<>(cacheParameter, new ObjectMapper());
redisUrl = Environment.getenv("REDIS_URL");
}
jedis = new UnifiedJedis(redisUrl);
jedis = new RedisAdapter(RedisClient.create(redisUrl));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

rename var

return switch (type) {
case LOCAL_CACHE_NAME -> new LocalCache<>(cacheDir, parameters);
case "redis" -> new RedisCache<>(parameters, mapper);
return switch (type.toLowerCase()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Enum

jedis = new UnifiedJedis(redisUrl);
jedis = new RedisAdapter(RedisClient.create(redisUrl));
// Check if connection is working
jedis.ping();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

check whether this is now a valid check for ping after you use the adapter


/**
* Integration test for the REST Redis interface.
* TODO: maybe testcontainer or something?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you can look into the rest-redis repo for examples with testcontainers

Comment thread pom.xml
Comment on lines +116 to +120
<dependency>
<groupId>org.fuchss</groupId>
<artifactId>rest-redis</artifactId>
<version>0.1.4</version>
</dependency>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remove jedis (because rest-redis has the jedis dependency already) :)

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.

3 participants