Skip to content

Commit 74ad5d3

Browse files
authored
Merge pull request #369 from BYTES-TECHES/caching
Fixed Issue #305
2 parents c952207 + 0726d4a commit 74ad5d3

6 files changed

Lines changed: 557 additions & 89 deletions

File tree

config/base.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ blacklist = []
3333
base_dir = "./uploads"
3434
max_file_size_mb = 10
3535

36+
[cache]
37+
redis_url = ""
38+
default_ttl_secs = 30
39+
events_ttl_secs = 10
40+
3641
[notification]
3742
email_api_url = "https://api.sendgrid.com"
3843
email_api_key = ""

indexer/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ A high-performance event indexing service for the Stellar Escrow smart contract
1010
- **WebSocket Streaming**: Real-time event broadcasting to connected clients
1111
- **Event Replay**: Replay historical events for catch-up or analysis
1212
- **Configurable**: Flexible configuration for different networks and contracts
13+
- **Redis Caching**: Read-through caching, invalidation, monitoring, and warming for hot API paths
1314

1415
## Architecture
1516

@@ -156,6 +157,14 @@ port = 3000
156157
url = "postgres://user:password@localhost/stellar_escrow"
157158
```
158159

160+
### Cache Configuration
161+
```toml
162+
[cache]
163+
redis_url = "redis://:password@localhost:6379"
164+
default_ttl_secs = 30
165+
events_ttl_secs = 10
166+
```
167+
159168
### Stellar Configuration
160169
```toml
161170
[stellar]
@@ -210,4 +219,4 @@ The service provides health check endpoints and comprehensive logging. Monitor:
210219

211220
## License
212221

213-
This project is licensed under the MIT License.
222+
This project is licensed under the MIT License.

indexer/src/cache.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,8 @@ impl Cache {
8181
let _: Result<(), _> = redis::cmd("DEL").arg(&keys).query_async(&mut conn).await;
8282
}
8383
}
84+
85+
pub fn is_connected(&self) -> bool {
86+
self.client.is_some()
87+
}
8488
}

0 commit comments

Comments
 (0)