-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleCacheDbTuningConfig.java
More file actions
73 lines (70 loc) · 3.43 KB
/
Copy pathSampleCacheDbTuningConfig.java
File metadata and controls
73 lines (70 loc) · 3.43 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package com.example.cachedb.sample.config;
import com.reactor.cachedb.core.cache.CachePolicy;
import com.reactor.cachedb.core.config.ReadShapeGuardrailConfig;
import com.reactor.cachedb.core.config.ReadThroughConfig;
import com.reactor.cachedb.core.config.ReadThroughMode;
import com.reactor.cachedb.core.config.RedisGuardrailConfig;
import com.reactor.cachedb.core.config.ResourceLimits;
import com.reactor.cachedb.core.config.SchemaBootstrapConfig;
import com.reactor.cachedb.core.config.SchemaBootstrapMode;
import com.reactor.cachedb.core.config.WriteBehindConfig;
import com.reactor.cachedb.spring.boot.CacheDatabaseConfigCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SampleCacheDbTuningConfig {
@Bean
CacheDatabaseConfigCustomizer sampleCacheDbTuning() {
return (builder, properties) -> builder
.resourceLimits(ResourceLimits.builder()
.defaultCachePolicy(CachePolicy.builder()
.hotEntityLimit(5_000)
.pageSize(50)
.entityTtlSeconds(0)
.pageTtlSeconds(90)
.countWindow()
.build())
.maxRegisteredEntities(128)
.maxColumnsPerOperation(64)
.build())
.readShapeGuardrail(ReadShapeGuardrailConfig.builder()
.enabled(true)
.maxEntityQueryLimit(250)
.maxProjectionQueryLimit(1_000)
.hotSetHeadroom(10)
.build())
.readThrough(ReadThroughConfig.builder()
.mode(ReadThroughMode.REDIS_ONLY)
.failOnMissingLoader(false)
.hydrateLoadedEntities(false)
.maxQueryLoadRows(1_000)
.queryTimeoutSeconds(15)
.build())
.redisGuardrail(RedisGuardrailConfig.builder()
.enabled(true)
.producerBackpressureEnabled(true)
.usedMemoryWarnMaxmemoryPercent(75)
.usedMemoryCriticalMaxmemoryPercent(88)
.expectedMaxmemoryPolicy("noeviction")
.warnOnMissingMaxmemory(true)
.writeBehindBacklogWarnThreshold(500)
.writeBehindBacklogCriticalThreshold(2_000)
.automaticRuntimeProfileSwitchingEnabled(true)
.build())
.schemaBootstrap(SchemaBootstrapConfig.builder()
.mode(SchemaBootstrapMode.VALIDATE_ONLY)
.autoApplyOnStart(true)
.build())
.writeBehind(WriteBehindConfig.builder()
.workerThreads(2)
.batchSize(128)
.maxFlushBatchSize(128)
.tableAwareBatchingEnabled(true)
.batchFlushEnabled(true)
.coalescingEnabled(true)
.maxFlushRetries(5)
.retryBackoffMillis(500)
.statementTimeoutSeconds(20)
.build());
}
}