-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleScheduledWarmPlans.java
More file actions
42 lines (36 loc) · 1.81 KB
/
Copy pathSampleScheduledWarmPlans.java
File metadata and controls
42 lines (36 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.example.cachedb.sample.config;
import com.example.cachedb.sample.repository.OrderRepository;
import com.reactor.cachedb.spring.boot.CacheScheduledWarm;
import com.reactor.cachedb.starter.CacheWarmPlan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.time.Instant;
@Component
public class SampleScheduledWarmPlans {
private final OrderRepository orders;
private final int orderWarmMaxRows;
public SampleScheduledWarmPlans(
OrderRepository orders,
@Value("${sample.scheduled-warm.orders.warm-max-rows:1000}") int orderWarmMaxRows
) {
this.orders = orders;
this.orderWarmMaxRows = Math.max(1, orderWarmMaxRows);
}
@CacheScheduledWarm(
name = "sample-active-order-window",
enabledString = "${sample.scheduled-warm.enabled:true}",
fixedDelayString = "${sample.scheduled-warm.orders.fixed-delay:PT15M}",
initialDelayString = "${sample.scheduled-warm.orders.initial-delay:PT30S}",
lockAtMostForString = "${sample.scheduled-warm.orders.lock-at-most-for:PT2M}",
lockWaitTimeoutString = "${sample.scheduled-warm.orders.lock-wait-timeout:PT20S}",
minimumIntervalString = "${sample.scheduled-warm.orders.minimum-interval:PT15M}",
reconcileHotSet = true,
reconcileMaxRowsPerRunString = "${sample.scheduled-warm.orders.reconcile-max-rows:10000}",
reconcileScanCountString = "${sample.scheduled-warm.orders.reconcile-scan-count:500}"
)
public CacheWarmPlan activeOrderWindow() {
long cutoffEpochSeconds = Instant.now().minus(Duration.ofDays(90)).getEpochSecond();
return orders.warmActiveWindow(cutoffEpochSeconds, orderWarmMaxRows);
}
}