feat(cache): Add lightweight in-memory cache with TTL and LRU eviction

This commit is contained in:
cogwheel0
2025-11-22 21:53:14 +05:30
parent 8ed75f8f14
commit c4a36bb51c
14 changed files with 1298 additions and 242 deletions

View File

@@ -35,16 +35,27 @@ class BackendConfig {
}
Map<String, dynamic> toJson() {
return <String, dynamic>{'enable_websocket': enableWebsocket};
return <String, dynamic>{
'enable_websocket': enableWebsocket,
};
}
static BackendConfig fromJson(Map<String, dynamic> json) {
bool? enableWebsocket;
final features = json['features'];
if (features is Map<String, dynamic>) {
final value = features['enable_websocket'];
if (value is bool) {
enableWebsocket = value;
// Try canonical format first
final value = json['enable_websocket'];
if (value is bool) {
enableWebsocket = value;
}
// Fallback to nested format for backwards compatibility
if (enableWebsocket == null) {
final features = json['features'];
if (features is Map<String, dynamic>) {
final nestedValue = features['enable_websocket'];
if (nestedValue is bool) {
enableWebsocket = nestedValue;
}
}
}