Files
WrBug b13aef944c refactor: 统一使用 MarketService 并改用 LRU 缓存
主要改进:
1. 将 MarketService 缓存从 ConcurrentHashMap 改为 Caffeine LRU 缓存
   - 最多缓存 200 条市场记录
   - 自动淘汰最近最少使用的记录
   - 提高缓存命中率和性能

2. 添加 Caffeine 依赖 (com.github.ben-manes.caffeine:caffeine:3.1.8)

3. 重构以下服务,统一使用 MarketService 获取市场信息:
   - OrderPushService: 删除 fetchMarketInfo() 方法,直接使用 MarketService
   - CopyOrderTrackingService: 移除直接调用 Gamma API 的代码
   - AccountService: 订单通知中使用 MarketService
   - OrderStatusUpdateService: 买入/卖出订单通知使用 MarketService

优势:
- 减少重复的 API 调用,利用三级缓存(内存 → 数据库 → API)
- 提高代码一致性和可维护性
- 统一市场数据获取逻辑,便于后续扩展
2026-01-08 18:33:49 +08:00

90 lines
2.7 KiB
Kotlin

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "3.2.0"
id("io.spring.dependency-management") version "1.1.4"
kotlin("jvm") version "1.9.20"
kotlin("plugin.spring") version "1.9.20"
kotlin("plugin.jpa") version "1.9.20"
}
group = "com.wrbug"
version = "1.0.0"
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
// Spring Boot
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-websocket")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
// Kotlin
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
// Retrofit
implementation("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
// OkHttp
implementation("com.squareup.okhttp3:okhttp:4.12.0")
// WebSocket Client
implementation("org.java-websocket:Java-WebSocket:1.5.4")
// Database
implementation("com.mysql:mysql-connector-j:8.2.0")
implementation("org.flywaydb:flyway-core")
implementation("org.flywaydb:flyway-mysql")
// Jackson
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("com.fasterxml.jackson.core:jackson-databind")
// Keccak-256 for Ethereum function selector
implementation("org.bouncycastle:bcprov-jdk18on:1.78.1")
// Web3j for Ethereum wallet and EIP-712 signing
implementation("org.web3j:core:5.0.0")
// JWT
implementation("io.jsonwebtoken:jjwt-api:0.12.3")
implementation("io.jsonwebtoken:jjwt-impl:0.12.3")
implementation("io.jsonwebtoken:jjwt-jackson:0.12.3")
// BCrypt for password encryption
implementation("org.springframework.security:spring-security-crypto:6.2.2")
// Logging
implementation("org.slf4j:slf4j-api")
// Caffeine Cache (LRU)
implementation("com.github.ben-manes.caffeine:caffeine:3.1.8")
// Test
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs += "-Xjsr305=strict"
jvmTarget = "17"
}
}
tasks.withType<Test> {
useJUnitPlatform()
}