Add app source and tests
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
24
lib/Peach/about/external/data/Redis.dart
vendored
Normal file
24
lib/Peach/about/external/data/Redis.dart
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/// 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';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user