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 {
88}
99
1010group = " hyeon9mak"
11- version = " 2.2.0 -spring-boot-3"
11+ version = " 2.2.1 -spring-boot-3"
1212
1313java {
1414 toolchain {
Original file line number Diff line number Diff line change @@ -2,16 +2,25 @@ package hyeon9mak.multidatasourcequerycounter
22
33import org.springframework.stereotype.Component
44import org.springframework.web.context.annotation.RequestScope
5+ import java.util.concurrent.atomic.AtomicInteger
6+ import java.util.concurrent.atomic.AtomicLong
7+
58
69@RequestScope
710@Component
811data class QueryCountPerRequest (
912 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) ,
1215) {
16+ val totalQueryCount: Int
17+ get() = _totalQueryCount .get()
18+
19+ val totalQueryMilliSeconds: Long
20+ get() = _totalQueryMilliSeconds .get()
21+
1322 fun incrementQueryCount (executionMilliSeconds : Long ) {
14- totalQueryCount ++
15- totalQueryMilliSeconds + = executionMilliSeconds
23+ _totalQueryCount = AtomicInteger ( _totalQueryCount .incrementAndGet())
24+ _totalQueryMilliSeconds = AtomicLong ( _totalQueryMilliSeconds .addAndGet( executionMilliSeconds))
1625 }
1726}
You can’t perform that action at this time.
0 commit comments