File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
src/main/java/hyeon9mak/multidatasourcequerycounter Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ plugins {
8
8
}
9
9
10
10
group = " hyeon9mak"
11
- version = " 2.2.0 -spring-boot-3"
11
+ version = " 2.2.1 -spring-boot-3"
12
12
13
13
java {
14
14
toolchain {
Original file line number Diff line number Diff line change @@ -2,16 +2,25 @@ package hyeon9mak.multidatasourcequerycounter
2
2
3
3
import org.springframework.stereotype.Component
4
4
import org.springframework.web.context.annotation.RequestScope
5
+ import java.util.concurrent.atomic.AtomicInteger
6
+ import java.util.concurrent.atomic.AtomicLong
7
+
5
8
6
9
@RequestScope
7
10
@Component
8
11
data class QueryCountPerRequest (
9
12
var apiUrl : String = " " ,
10
- var totalQueryCount : Int = 0 ,
11
- var totalQueryMilliSeconds : Long = 0L ,
13
+ private var _totalQueryCount : AtomicInteger = AtomicInteger (0) ,
14
+ private var _totalQueryMilliSeconds : AtomicLong = AtomicLong (0L) ,
12
15
) {
16
+ val totalQueryCount: Int
17
+ get() = _totalQueryCount .get()
18
+
19
+ val totalQueryMilliSeconds: Long
20
+ get() = _totalQueryMilliSeconds .get()
21
+
13
22
fun incrementQueryCount (executionMilliSeconds : Long ) {
14
- totalQueryCount ++
15
- totalQueryMilliSeconds + = executionMilliSeconds
23
+ _totalQueryCount = AtomicInteger ( _totalQueryCount .incrementAndGet())
24
+ _totalQueryMilliSeconds = AtomicLong ( _totalQueryMilliSeconds .addAndGet( executionMilliSeconds))
16
25
}
17
26
}
You can’t perform that action at this time.
0 commit comments