getPreloadedProxies method
Gets preloaded proxies from the cache
Implementation
List<ProxyModel> getPreloadedProxies({int count = 10}) {
// First try to get proxies from the primary cache
var proxies = _cacheManager.getProxiesFromTier(CacheTier.primary);
// If we don't have enough, get from the secondary cache
if (proxies.length < count) {
proxies = [
...proxies,
..._cacheManager.getProxiesFromTier(CacheTier.secondary),
];
}
// If we still don't have enough, get from the tertiary cache
if (proxies.length < count) {
proxies = [
...proxies,
..._cacheManager.getProxiesFromTier(CacheTier.tertiary),
];
}
// Sort by score
proxies.sort((a, b) {
final aScore = a.score?.calculateScore() ?? 0;
final bScore = b.score?.calculateScore() ?? 0;
return bScore.compareTo(aScore);
});
// Return the top N proxies
return proxies.take(count).toList();
}