traxxx-web/src/cache.js

22 lines
443 B
JavaScript

import redis from './redis.js';
export async function getIdsBySlug(slugs, domain) {
const ids = await Promise.all(slugs.map(async (slug) => {
if (!slug) {
return null;
}
/* this, naturally, fails if the slug is 69 etc.
if (Number(slug)) {
return Number(slug); // already an ID or missing
}
*/
const id = await redis.hGet(`traxxx:${domain}:id_by_slug`, slug);
return Number(id);
}));
return ids.filter(Boolean);
}