Skip to content

Commit b8c04ae

Browse files
authored
[inmemory] Default persistence strategy Forecast (openhab#16496)
* default forecast persistence strategy Signed-off-by: Mark Herwege <[email protected]>
1 parent 9a6258b commit b8c04ae

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bundles/org.openhab.persistence.inmemory/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Because of that the `restoreOnStartup` strategy is not supported for this servic
55

66
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.
77

8-
Since all data is stored in memory only, there is no default strategy for this service.
8+
The default strategy for this service is `forecast`.
99
Unlike other persistence services, you MUST add a configuration, otherwise no data will be persisted.
1010
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.
1111

bundles/org.openhab.persistence.inmemory/src/main/java/org/openhab/persistence/inmemory/internal/InMemoryPersistenceService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ public Iterable<HistoricItem> query(FilterCriteria filter) {
188188

189189
@Override
190190
public List<PersistenceStrategy> getDefaultStrategies() {
191-
// persist nothing by default
192-
return List.of();
191+
// persist only forecasts by default
192+
return List.of(PersistenceStrategy.Globals.FORECAST);
193193
}
194194

195195
private PersistenceItemInfo toItemInfo(Map.Entry<String, PersistItem> itemEntry) {
@@ -268,7 +268,7 @@ private void internalStore(String itemName, ZonedDateTime timestamp, State state
268268
}
269269
}
270270

271-
@SuppressWarnings({ "rawType", "unchecked" })
271+
@SuppressWarnings("unchecked")
272272
private boolean applies(PersistEntry entry, FilterCriteria filter) {
273273
ZonedDateTime beginDate = filter.getBeginDate();
274274
if (beginDate != null && beginDate.isAfter(entry.timestamp())) {

0 commit comments

Comments
 (0)