11 lines
459 B
JavaScript
11 lines
459 B
JavaScript
export async function cachedLoras({read,write,live,fresh=false}) {
|
|
const cached=read() || {image:[],video:[]};
|
|
if (!fresh && (cached.image?.length || cached.video?.length)) return cached;
|
|
try {
|
|
const listed=await live();
|
|
const next={image:listed.image?.length?listed.image:cached.image||[],video:listed.video?.length?listed.video:cached.video||[]};
|
|
if(next.image.length || next.video.length) write(next);
|
|
return next;
|
|
} catch { return cached; }
|
|
}
|