From 6884604ce39b867688864b6b5f2e5f7ae8aa9af1 Mon Sep 17 00:00:00 2001 From: EzPlugins Date: Tue, 7 Jul 2026 20:36:42 +0200 Subject: [PATCH] Delete .kilo directory --- .kilo/plans/1780618544813-proud-moon.md | 99 ------------------------- 1 file changed, 99 deletions(-) delete mode 100644 .kilo/plans/1780618544813-proud-moon.md diff --git a/.kilo/plans/1780618544813-proud-moon.md b/.kilo/plans/1780618544813-proud-moon.md deleted file mode 100644 index 11d2f6c..0000000 --- a/.kilo/plans/1780618544813-proud-moon.md +++ /dev/null @@ -1,99 +0,0 @@ -# Plan: Redis Cache Support for Stock Market Transactions - -## Overview -Add configurable Redis-based caching for stock market transaction amounts, falling back to local in-memory cache (current implementation) by default. - -## Current State -- `StockMarketManager` has a `pendingTransactions` ConcurrentHashMap for batching updates -- Updates are flushed every `flushIntervalTicks` (default 1 second) -- Price persistence happens every `saveIntervalTicks` (configurable, default 5 minutes) -- Storage uses `StockMarketRepository` with YML implementation - -## Proposed Architecture - -### 1. Create TransactionCache Interface -Create `com.skyblockexp.ezshops.data.TransactionCache` interface: -```java -public interface TransactionCache { - void add(String productId, int amount); - Map drain(); - int get(String productId); - boolean isEmpty(); - void clear(); -} -``` - -### 2. Implement LocalTransactionCache (Default) -- Rename current `pendingTransactions` map to be a separate class -- Keep current ConcurrentHashMap-based implementation as default - -### 3. Implement RedisTransactionCache -- Use Redisson library (already used by PaperMC ecosystem) or Jedis -- Store pending amounts in Redis hash with TTL -- Key pattern: `ezshops:stock:pending:{productId}` or `ezshops:stock:transactions` hash -- Provide async operations to avoid blocking main thread - -### 4. Update Configuration (`config.yml`) -Add under `stock:` section: -```yaml -stock: - cache: - # Cache type: LOCAL (default) or REDIS - type: LOCAL - # Redis connection settings (used when type: REDIS) - redis: - host: localhost - port: 6379 - password: "" - # Flush interval in seconds (how often batched updates are processed) - flush-interval-seconds: 5 -``` - -### 5. Update StockComponent Bootstrap -- Read cache configuration -- Create appropriate `TransactionCache` implementation -- Inject into `StockMarketManager` -- Handle Redis connection lifecycle - -### 6. Update StockMarketManager -- Add `TransactionCache transactionCache` field -- Replace direct `pendingTransactions` access with cache methods -- Add method to configure cache after construction - -### 7. Add Redis Dependency Options -Option A: Redisson (comprehensive, handles connection pooling) -Option B: Jedis (minimal, requires more manual management) -Recommendation: Use Redisson as soft dependency (already compatible with shading) - -## Implementation Steps - -1. **Create TransactionCache interface** (`src/main/java/com/skyblockexp/ezshops/data/TransactionCache.java`) - -2. **Create LocalTransactionCache** (`src/main/java/com/skyblockexp/ezshops/data/LocalTransactionCache.java`) - - Wrap current ConcurrentHashMap logic - -3. **Create RedisTransactionCache** (`src/main/java/com/skyblockexp/ezshops/data/RedisTransactionCache.java`) - - Implement with Redisson or Jedis - - Handle connection failures gracefully with fallback to local cache - -4. **Update StockMarketManager.configureCache()** method to accept TransactionCache - -5. **Update StockComponent.enable()** to: - - Parse cache configuration - - Instantiate appropriate cache - - Handle Redis unavailability gracefully - -6. **Update config.yml** with cache configuration options - -7. **Add maven dependencies** in pom.xml (Redisson or Jedis as provided scope) - -## Fallback Behavior -- If Redis fails to connect, fall back to LOCAL cache -- Log warning about fallback -- Continue operation normally - -## Testing Strategy -- Unit tests for LocalTransactionCache (trivial - wrap existing tests) -- Integration tests for RedisTransactionCache using embedded Redis or mock -- Test fallback behavior when Redis unavailable -- Test concurrent access patterns \ No newline at end of file