Make Cache Configurable#75
Merged
dfuchss merged 36 commits intoJul 15, 2026
Merged
Conversation
- add new redis cache replacement strategy
…pdate CacheManager to support initialization from ModuleConfiguration
…tegy to be more generic
…RedisCache to simplify as a regular cache
…e/add-cache-configurations # Conflicts: # src/main/java/edu/kit/kastel/sdq/lissa/ratlr/configuration/EvaluationConfiguration.java
dfuchss
marked this pull request as draft
April 29, 2026 19:13
…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.
…ion, and backward compatibility checks
Contributor
There was a problem hiding this comment.
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.
…e non-empty list. Also fail fast if configured caches are unavailable
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
dfuchss
approved these changes
Jun 24, 2026
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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>
|
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); | ||
| }; | ||
| } |
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) { |
| 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. |
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.



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.