Skip to content

Commit 9048994

Browse files
committed
merge
2 parents 4e516e8 + a35d421 commit 9048994

File tree

14 files changed

+343
-372
lines changed

14 files changed

+343
-372
lines changed

README.adoc

Lines changed: 185 additions & 195 deletions
Large diffs are not rendered by default.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.2-SNAPSHOT
1+
0.3.1-SNAPSHOT

core/redis-smart-cache-core/src/main/java/com/redis/smartcache/core/Config.java

Lines changed: 14 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
package com.redis.smartcache.core;
22

3-
import java.beans.PropertyChangeListener;
4-
import java.beans.PropertyChangeSupport;
5-
import java.util.*;
6-
import java.util.concurrent.TimeUnit;
7-
83
import io.airlift.units.DataSize;
94
import io.airlift.units.DataSize.Unit;
105
import io.airlift.units.Duration;
116
import io.lettuce.core.SslVerifyMode;
127

8+
import java.util.Objects;
9+
import java.util.concurrent.TimeUnit;
10+
1311

1412
public class Config {
1513

1614
public static final String DEFAULT_NAME = "smartcache";
15+
public static final int DEFAULT_QUERY_CACHE_CAPACITY = 10000;
1716

1817
private String name = DEFAULT_NAME;
18+
private int queryCacheCapacity = DEFAULT_QUERY_CACHE_CAPACITY;
19+
1920
private DriverConfig driver = new DriverConfig();
2021
private RedisConfig redis = new RedisConfig();
2122
private RulesetConfig ruleset = new RulesetConfig();
2223
private MetricsConfig metrics = new MetricsConfig();
23-
private AnalyzerConfig analyzer = new AnalyzerConfig();
2424

2525
public String getName() {
2626
return name;
@@ -30,6 +30,14 @@ public void setName(String name) {
3030
this.name = name;
3131
}
3232

33+
public int getQueryCacheCapacity() {
34+
return queryCacheCapacity;
35+
}
36+
37+
public void setQueryCacheCapacity(int capacity) {
38+
this.queryCacheCapacity = capacity;
39+
}
40+
3341
public DriverConfig getDriver() {
3442
return driver;
3543
}
@@ -62,14 +70,6 @@ public void setMetrics(MetricsConfig metrics) {
6270
this.metrics = metrics;
6371
}
6472

65-
public AnalyzerConfig getAnalyzer() {
66-
return analyzer;
67-
}
68-
69-
public void setAnalyzer(AnalyzerConfig analyzer) {
70-
this.analyzer = analyzer;
71-
}
72-
7373
@Override
7474
public int hashCode() {
7575
return Objects.hash(redis.getUri(), name);
@@ -234,62 +234,6 @@ public boolean equals(Object obj) {
234234

235235
}
236236

237-
public static class AnalyzerConfig {
238-
239-
public static final int DEFAULT_QUEUE_CAPACITY = 10000;
240-
public static final int DEFAULT_THREAD_COUNT = 1;
241-
public static final Duration DEFAULT_FLUSH_INTERVAL = new Duration(50, TimeUnit.MILLISECONDS);
242-
public static final int DEFAULT_BATCH_SIZE = 50;
243-
public static final int DEFAULT_CACHE_CAPACITY = 10000;
244-
245-
private int cacheCapacity = DEFAULT_CACHE_CAPACITY;
246-
private int queueCapacity = DEFAULT_QUEUE_CAPACITY;
247-
private int batchSize = DEFAULT_BATCH_SIZE;
248-
private int threads = DEFAULT_THREAD_COUNT;
249-
private Duration flushInterval = DEFAULT_FLUSH_INTERVAL;
250-
251-
public Duration getFlushInterval() {
252-
return flushInterval;
253-
}
254-
255-
public void setFlushInterval(Duration interval) {
256-
this.flushInterval = interval;
257-
}
258-
259-
public int getCacheCapacity() {
260-
return cacheCapacity;
261-
}
262-
263-
public void setCacheCapacity(int capacity) {
264-
this.cacheCapacity = capacity;
265-
}
266-
267-
public int getQueueCapacity() {
268-
return queueCapacity;
269-
}
270-
271-
public void setQueueCapacity(int queueCapacity) {
272-
this.queueCapacity = queueCapacity;
273-
}
274-
275-
public int getBatchSize() {
276-
return batchSize;
277-
}
278-
279-
public void setBatchSize(int batchSize) {
280-
this.batchSize = batchSize;
281-
}
282-
283-
public int getThreads() {
284-
return threads;
285-
}
286-
287-
public void setThreads(int threads) {
288-
this.threads = threads;
289-
}
290-
291-
}
292-
293237
public static class DriverConfig {
294238

295239
private String className;
@@ -312,5 +256,4 @@ public void setUrl(String url) {
312256
}
313257

314258
}
315-
316259
}

core/redis-smart-cache-core/src/main/java/com/redis/smartcache/core/Mappers.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.Properties;
55

66
import com.fasterxml.jackson.annotation.JsonInclude.Include;
7-
import com.fasterxml.jackson.databind.DeserializationFeature;
87
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
98
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsMapper;
109
import com.fasterxml.jackson.dataformat.javaprop.JavaPropsSchema;
@@ -23,8 +22,7 @@ private Mappers() {
2322

2423
public static JavaPropsMapper propsMapper() {
2524
return JavaPropsMapper.builder().serializationInclusion(Include.NON_NULL)
26-
.propertyNamingStrategy(PropertyNamingStrategies.KEBAB_CASE)
27-
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).build();
25+
.propertyNamingStrategy(PropertyNamingStrategies.KEBAB_CASE).build();
2826
}
2927

3028
public static Properties properties(Config config) throws IOException {

core/redis-smart-cache-core/src/main/java/com/redis/smartcache/core/RuleConfig.java

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
import java.util.Objects;
1111
import java.util.concurrent.TimeUnit;
1212

13-
public class RuleConfig implements Cloneable {
13+
public class RuleConfig implements Cloneable{
1414

15-
public static final Duration DEFAULT_TTL = new Duration(1, TimeUnit.HOURS);
15+
public static final Duration TTL_NO_CACHING = Duration.succinctNanos(0);
16+
public static final Duration DEFAULT_TTL = TTL_NO_CACHING;
1617

1718
private final PropertyChangeSupport support = new PropertyChangeSupport(this);
1819

1920
private List<String> tables;
2021
private List<String> tablesAny;
2122
private List<String> tablesAll;
2223
private String regex;
23-
2424
private List<String> queryIds;
25-
private Duration ttl = DEFAULT_TTL;
25+
private Duration ttl = TTL_NO_CACHING;
2626

2727
public RuleConfig() {
2828
}
2929

30-
private RuleConfig(RuleConfig.Builder builder) {
30+
private RuleConfig(Builder builder) {
3131
this.tables = builder.tables;
3232
this.tablesAny = builder.tablesAny;
3333
this.tablesAll = builder.tablesAll;
@@ -36,30 +36,6 @@ private RuleConfig(RuleConfig.Builder builder) {
3636
this.ttl = builder.ttl;
3737
}
3838

39-
@Override
40-
public RuleConfig clone(){
41-
RuleConfig res = new RuleConfig();
42-
if (tables != null){
43-
res.tables = new ArrayList<>(this.tables);
44-
}
45-
46-
if (tablesAll != null){
47-
res.tablesAll = new ArrayList<>(this.tablesAll);
48-
}
49-
50-
if (tablesAny != null){
51-
res.tablesAny = new ArrayList<>(this.tablesAny);
52-
}
53-
54-
if (queryIds != null){
55-
res.queryIds = new ArrayList<>(this.queryIds);
56-
}
57-
58-
res.regex = this.regex;
59-
res.ttl = this.ttl;
60-
return res;
61-
}
62-
6339
public void addPropertyChangeListener(PropertyChangeListener listener) {
6440
support.addPropertyChangeListener(listener);
6541
}
@@ -151,38 +127,62 @@ public boolean equals(Object obj) {
151127
&& Objects.equals(tablesAny, other.tablesAny) && Objects.equals(ttl, other.ttl);
152128
}
153129

154-
public static RuleConfig.Builder tables(String... tables) {
155-
RuleConfig.Builder builder = new RuleConfig.Builder();
130+
@Override
131+
public RuleConfig clone(){
132+
RuleConfig res = new RuleConfig();
133+
if (tables != null){
134+
res.tables = new ArrayList<>(this.tables);
135+
}
136+
137+
if (tablesAll != null){
138+
res.tablesAll = new ArrayList<>(this.tablesAll);
139+
}
140+
141+
if (tablesAny != null){
142+
res.tablesAny = new ArrayList<>(this.tablesAny);
143+
}
144+
145+
if (queryIds != null){
146+
res.queryIds = new ArrayList<>(this.queryIds);
147+
}
148+
149+
res.regex = this.regex;
150+
res.ttl = this.ttl;
151+
return res;
152+
}
153+
154+
public static Builder tables(String... tables) {
155+
Builder builder = new Builder();
156156
builder.tables = Arrays.asList(tables);
157157
return builder;
158158
}
159159

160-
public static RuleConfig.Builder tablesAny(String... tables) {
161-
RuleConfig.Builder builder = new RuleConfig.Builder();
160+
public static Builder tablesAny(String... tables) {
161+
Builder builder = new Builder();
162162
builder.tablesAny = Arrays.asList(tables);
163163
return builder;
164164
}
165165

166-
public static RuleConfig.Builder tablesAll(String... tables) {
167-
RuleConfig.Builder builder = new RuleConfig.Builder();
166+
public static Builder tablesAll(String... tables) {
167+
Builder builder = new Builder();
168168
builder.tablesAll = Arrays.asList(tables);
169169
return builder;
170170
}
171171

172-
public static RuleConfig.Builder queryIds(String... ids) {
173-
RuleConfig.Builder builder = new RuleConfig.Builder();
172+
public static Builder queryIds(String... ids) {
173+
Builder builder = new Builder();
174174
builder.queryIds = Arrays.asList(ids);
175175
return builder;
176176
}
177177

178-
public static RuleConfig.Builder regex(String regex) {
179-
RuleConfig.Builder builder = new RuleConfig.Builder();
178+
public static Builder regex(String regex) {
179+
Builder builder = new Builder();
180180
builder.regex = regex;
181181
return builder;
182182
}
183183

184-
public static RuleConfig.Builder passthrough() {
185-
return new RuleConfig.Builder();
184+
public static Builder passthrough() {
185+
return new Builder();
186186
}
187187

188188
public static final class Builder {
@@ -194,35 +194,35 @@ public static final class Builder {
194194
private List<String> queryIds;
195195
private Duration ttl = DEFAULT_TTL;
196196

197-
public Builder() {
197+
private Builder() {
198198
}
199199

200-
public RuleConfig.Builder tables(String... tables) {
200+
public Builder tables(String... tables) {
201201
this.tables = Arrays.asList(tables);
202202
return this;
203203
}
204204

205-
public RuleConfig.Builder tablesAny(String... tables) {
205+
public Builder tablesAny(String... tables) {
206206
this.tablesAny = Arrays.asList(tables);
207207
return this;
208208
}
209209

210-
public RuleConfig.Builder tablesAll(String... tables) {
210+
public Builder tablesAll(String... tables) {
211211
this.tablesAll = Arrays.asList(tables);
212212
return this;
213213
}
214214

215-
public RuleConfig.Builder regex(String regex) {
215+
public Builder regex(String regex) {
216216
this.regex = regex;
217217
return this;
218218
}
219219

220-
public RuleConfig.Builder queryIds(String... ids) {
220+
public Builder queryIds(String... ids) {
221221
this.queryIds = Arrays.asList(ids);
222222
return this;
223223
}
224224

225-
public RuleConfig.Builder ttl(Duration ttl) {
225+
public Builder ttl(Duration ttl) {
226226
this.ttl = ttl;
227227
return this;
228228
}

0 commit comments

Comments
 (0)