Files
alvocool 38881d1fe1 Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-11 10:15:30 +03:00

25 lines
726 B
Dart

/// A single Redis key's type, TTL and (formatted) value.
class RedisEntry {
final String key;
final String type; // string | list | set | hash | zset | stream | none
final String ttl; // seconds, -1 (no expiry), -2 (missing)
final String value;
RedisEntry({
required this.key,
required this.type,
required this.ttl,
required this.value,
});
String get ttlLabel {
final n = int.tryParse(ttl.trim());
if (n == null) return ttl;
if (n == -1) return 'no expiry';
if (n == -2) return 'missing';
if (n < 60) return '${n}s';
if (n < 3600) return '${(n / 60).floor()}m ${n % 60}s';
if (n < 86400) return '${(n / 3600).floor()}h';
return '${(n / 86400).floor()}d';
}
}