Make Cache Configurable#75
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
…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
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.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…propriate methods to avoid serialization conflicts
|
…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>
| String jsonValue; | ||
| try { | ||
| jsonValue = mapper.writeValueAsString(Objects.requireNonNull(value)); | ||
| } catch (JsonProcessingException e) { | ||
| throw new IllegalArgumentException("Could not serialize object", e); | ||
| } |
| 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); | ||
| }; | ||
| } |
| /** | ||
| * Rule that enforces that CacheManager.resetDefaultInstance() is only called from Test classes. | ||
| * <p> | ||
| * The resetDefaultInstance() method should only be used to reset the singleton state between tests. | ||
| * It must never be called from production code or other test classes. | ||
| */ | ||
| @ArchTest | ||
| static final ArchRule cacheManagerResetOnlyInTests = noClasses() | ||
| .that() | ||
| .haveNameNotMatching(".*Test.*") | ||
| .should() | ||
| .callMethod(CacheManager.class, "resetDefaultInstance") | ||
| .because( | ||
| "CacheManager.resetDefaultInstance() is only intended for testing purposes in CacheTest and must not be used elsewhere"); | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|



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.