[inmemory] Default persistence strategy Forecast (#16496)

* default forecast persistence strategy

Signed-off-by: Mark Herwege <mark.herwege@telenet.be>
This commit is contained in:
Mark Herwege 2024-06-27 08:58:11 +02:00 committed by GitHub
parent 9a6258b405
commit b8c04ae424
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ Because of that the `restoreOnStartup` strategy is not supported for this servic
The main use-case is to store data that is needed during runtime, e.g. temporary storage of forecast data that is retrieved from a binding.
Since all data is stored in memory only, there is no default strategy for this service.
The default strategy for this service is `forecast`.
Unlike other persistence services, you MUST add a configuration, otherwise no data will be persisted.
To avoid excessive memory usage, it is recommended to persist only a limited number of items and use a strategy that stores only data that is actually needed.

View File

@ -188,8 +188,8 @@ public class InMemoryPersistenceService implements ModifiablePersistenceService
@Override
public List<PersistenceStrategy> getDefaultStrategies() {
// persist nothing by default
return List.of();
// persist only forecasts by default
return List.of(PersistenceStrategy.Globals.FORECAST);
}
private PersistenceItemInfo toItemInfo(Map.Entry<String, PersistItem> itemEntry) {
@ -268,7 +268,7 @@ public class InMemoryPersistenceService implements ModifiablePersistenceService
}
}
@SuppressWarnings({ "rawType", "unchecked" })
@SuppressWarnings("unchecked")
private boolean applies(PersistEntry entry, FilterCriteria filter) {
ZonedDateTime beginDate = filter.getBeginDate();
if (beginDate != null && beginDate.isAfter(entry.timestamp())) {