Skip to content

feat:Add Redis Cache Layer for Session History and Statistics Queries - #12

Open
AvAn0sch wants to merge 1 commit into
Kahiy314:mainfrom
AvAn0sch:feature/AvAn0_fix
Open

feat:Add Redis Cache Layer for Session History and Statistics Queries#12
AvAn0sch wants to merge 1 commit into
Kahiy314:mainfrom
AvAn0sch:feature/AvAn0_fix

Conversation

@AvAn0sch

@AvAn0sch AvAn0sch commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Overview

Loading the History and Statistics pages currently takes 10–20 seconds. The root cause is that every query fully deserializes large JSON arrays from SharedPreferences and performs filtering and aggregation in memory.

This PR introduces a Redis cache layer at the SessionRepository interface level using the Decorator Pattern, providing caching with zero intrusion into existing business logic.


Verification

Successful initialization should produce logs similar to:

Redis cache connected: localhost:6379
Redis cache status: Available ✅

Redis Configuration

Configure Redis in Satori\satori_flutter\lib\app\providers.dart:

final redisCacheServiceProvider = Provider((ref) {
final host = Platform.isAndroid ? '10.0.2.2' : 'localhost';

final service = RedisCacheService(
host: host,
port: 6379,
password: null,
);

unawaited(service.initialize());

ref.onDispose(() => service.dispose());

return service;
});


Configuration Parameters

Parameter | Default | Description
host | localhost | Use 10.0.2.2 for Android Emulator; use localhost for iOS Simulator and desktop environments
port | 6379 | Redis server port
password | null | Redis password; leave as null if authentication is not required
ttlSeconds | 600 | Cache expiration time in seconds

Prerequisites

A local Redis instance must be running:

redis-server --port 6379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant