Array of manga titles to preload.
Optionaltoken: stringOptional authentication token.
Optional search service configuration overrides.
Promise resolving when preloading is complete.
export async function preloadCommonManga(
titles: string[],
token?: string,
config: Partial<SearchServiceConfig> = {},
): Promise<void> {
console.info(
`[MangaSearchService] 📥 Preloading ${titles.length} common manga titles...`,
);
const searchConfig = { ...DEFAULT_SEARCH_CONFIG, ...config };
// Process in batches to respect rate limits
let preloadedCount = 0;
for (let i = 0; i < titles.length; i += searchConfig.batchSize) {
const batch = titles.slice(i, i + searchConfig.batchSize);
// Process batch items in sequence with rate limiting
for (const title of batch) {
const cacheKey = generateCacheKey(title);
// Only search if not already in cache
if (!isCacheValid(cacheKey)) {
await searchMangaByTitle(title, token, searchConfig);
preloadedCount++;
}
}
}
console.info(
`[MangaSearchService] ✅ Preloading complete: ${preloadedCount} new titles cached`,
);
}
Preloads common manga titles into the cache.
Searches and caches frequently accessed titles to reduce subsequent API calls. Skips titles already in cache.