Skip to content

Make Cache Configurable#75

Merged
dfuchss merged 36 commits into
ardoco:mainfrom
DanielDango:feature/add-cache-configurations
Jul 15, 2026
Merged

Make Cache Configurable#75
dfuchss merged 36 commits into
ardoco:mainfrom
DanielDango:feature/add-cache-configurations

Conversation

@DanielDango

@DanielDango DanielDango commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

This PR aims to make caches in LiSSA configurable.
Caching with REST-Redis as in #59 can be added afterwards.

The current Redis and Local Cache implementations are split into independent implementations of the Cache interface. Instead, a new Cache, the hierarchical Cache, is added to define how two caches can be coupled. Hierarchical caches can also be coupled with another hierarchical cache. If values are missing in any level of the cache hierarchy, they will be propagated.

The CacheReplacementStrategy Enum describes different conflict resolution strategies (None / Error / Overwrite).
The strategy and general cache hierarchy are defined in environment variables with the defaults of local cache and no consequences on cache conflicts.

The internal local cache implementation has not been altered to keep support for existing local cache files. Their location continues to be specified by the configuration file to enable effortless replication.

Copilot AI review requested due to automatic review settings April 23, 2026 14:52
@DanielDango
DanielDango requested a review from dfuchss as a code owner April 23, 2026 14:52

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.

…e/add-cache-configurations

# Conflicts:
#	src/main/java/edu/kit/kastel/sdq/lissa/ratlr/configuration/EvaluationConfiguration.java
@dfuchss
dfuchss marked this pull request as draft April 29, 2026 19:13
@DanielDango
DanielDango marked this pull request as ready for review May 4, 2026 11:41
Copilot AI review requested due to automatic review settings May 4, 2026 11:41

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 11 out of 11 changed files in this pull request and generated 11 comments.


💡 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/cache/CacheReplacementStrategy.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheReplacementStrategy.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/HierarchicalCache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheManager.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/HierarchicalCache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheReplacementStrategy.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/CacheReplacementStrategy.java Outdated
Copilot AI review requested due to automatic review settings May 5, 2026 12:43
@DanielDango
DanielDango requested a review from dfuchss June 17, 2026 13:42
@DanielDango DanielDango changed the title WIP: Make Cache Configurable Make Cache Configurable Jun 17, 2026
@dfuchss
dfuchss requested a review from Copilot June 17, 2026 13:57

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 18 out of 18 changed files in this pull request and generated 7 comments.

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/RedisCache.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/Cache.java
Comment thread docs/caching.md Outdated
Comment thread src/test/java/edu/kit/kastel/sdq/lissa/ratlr/ArchitectureTest.java
Comment thread src/test/java/edu/kit/kastel/sdq/lissa/ratlr/ArchitectureTest.java
dfuchss and others added 3 commits June 20, 2026 23:32
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 18 out of 18 changed files in this pull request and generated 6 comments.

Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/utils/Environment.java Outdated
Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/LocalCache.java
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/Cache.java
Comment thread src/test/java/edu/kit/kastel/sdq/lissa/ratlr/ArchitectureTest.java
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 18 out of 18 changed files in this pull request and generated 3 comments.

Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/LocalCache.java Outdated
Comment on lines +135 to +140
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);
};
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 15, 2026 14:06
@sonarqubecloud

Copy link
Copy Markdown

@dfuchss
dfuchss merged commit 691ba59 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 18 out of 18 changed files in this pull request and generated 5 comments.

Comment thread src/main/java/edu/kit/kastel/sdq/lissa/ratlr/cache/LocalCache.java Outdated
Comment on lines +161 to +166
String jsonValue;
try {
jsonValue = mapper.writeValueAsString(Objects.requireNonNull(value));
} catch (JsonProcessingException e) {
throw new IllegalArgumentException("Could not serialize object", e);
}
Comment on lines +14 to 15
import redis.clients.jedis.RedisClient;
import redis.clients.jedis.UnifiedJedis;
Comment on lines +68 to +74
String redisUrl = "redis://localhost:6379";
if (Environment.getenv("REDIS_URL") != null) {
redisUrl = Environment.getenv("REDIS_URL");
}
jedis = RedisClient.create(redisUrl);
// Check if connection is working
jedis.ping();
Comment on lines +135 to +141
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);
};
}
Copilot AI review requested due to automatic review settings July 15, 2026 14:11

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 18 out of 18 changed files in this pull request and generated 6 comments.

Comment on lines +103 to +117
@SuppressWarnings("unchecked")
static <T> @Nullable T convert(@Nullable String jsonData, Class<T> clazz, ObjectMapper mapper) {
if (jsonData == null) {
return null;
}
try {
return mapper.readValue(jsonData, clazz);
} catch (JsonProcessingException e) {
// Backward compatibility for unserialized String values
if (clazz == String.class) {
return (T) jsonData;
}
throw new IllegalArgumentException("Could not deserialize object", e);
}
}
Comment on lines +135 to +141
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);
};
}
Comment on lines +128 to +131
* @param type The cache type name (case-insensitive)
* @param cacheDir The directory for local cache storage
* @param parameters The cache parameters
* @param mapper The ObjectMapper for JSON operations
e);
}
}
return cacheTypes;
}

@Override
public boolean containsKey(String key) {
Comment thread docs/caching.md
2. Set environment variables if needed:
- `CACHE_HIERARCHY=REDIS,LOCAL` to use Redis with local fallback
- `REDIS_URL=redis://your-redis-host:6379` if not using the default
3. If Redis is unavailable, but configured to be used the system will fail.
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