mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 08:26:59 +03:00
Add disk caching for youtube api calls
Fixes https://github.com/ajayyy/SponsorBlockServer/issues/239
This commit is contained in:
32
src/utils/diskCache.ts
Normal file
32
src/utils/diskCache.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import LRU from "@ajayyy/lru-diskcache";
|
||||
import { config } from "../config";
|
||||
|
||||
let DiskCache: LRU<string, string>;
|
||||
|
||||
if (config.diskCache) {
|
||||
DiskCache = new LRU('./databases/cache', config.diskCache);
|
||||
DiskCache.init();
|
||||
} else {
|
||||
DiskCache = {
|
||||
// constructor(rootPath, options): {};
|
||||
|
||||
init() {},
|
||||
|
||||
reset() {},
|
||||
|
||||
has(key) { return false; },
|
||||
|
||||
get(key, opts) { return null; },
|
||||
|
||||
// Returns size
|
||||
set(key, dataOrSteam) { return new Promise((resolve) => 0); },
|
||||
|
||||
del(key) {},
|
||||
|
||||
size() { return 0; },
|
||||
|
||||
prune() {},
|
||||
};
|
||||
}
|
||||
|
||||
export default DiskCache;
|
||||
Reference in New Issue
Block a user