many method
Retrieves multiple values from the cache by their keys.
Returns a map of key-value pairs. Keys not found in the cache will not be present in the returned map.
- Parameters:
keys: A list of keys to retrieve.
Implementation
@override
Future<Map<String, dynamic>> many(List<String> keys) async {
if (keys.isEmpty) return {};
final result = await _executeCommand(['MGET', ...keys], isRead: true);
final Map<String, dynamic> map = {};
if (result is List) {
for (int i = 0; i < keys.length; i++) {
if (result[i] != null) {
try {
map[keys[i]] = jsonDecode(result[i]);
} catch (_) {
map[keys[i]] = result[i];
}
}
}
}
return map;
}