mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-05-13 04:51:35 +02:00
Add FileCache model
This commit is contained in:
parent
d805da906a
commit
04c7e61fc0
7 changed files with 26 additions and 9 deletions
|
@ -14,7 +14,7 @@ import {TYPES} from '../types.js';
|
|||
import {cleanUrl} from '../utils/url.js';
|
||||
import ThirdParty from './third-party.js';
|
||||
import Config from './config.js';
|
||||
import CacheProvider from './cache.js';
|
||||
import KeyValueCacheProvider from './key-value-cache.js';
|
||||
|
||||
type QueuedSongWithoutChannel = Except<QueuedSong, 'addedInChannelId'>;
|
||||
|
||||
|
@ -26,14 +26,14 @@ export default class {
|
|||
private readonly youtube: YouTube;
|
||||
private readonly youtubeKey: string;
|
||||
private readonly spotify: Spotify;
|
||||
private readonly cache: CacheProvider;
|
||||
private readonly cache: KeyValueCacheProvider;
|
||||
|
||||
private readonly ytsrQueue: PQueue;
|
||||
|
||||
constructor(
|
||||
@inject(TYPES.ThirdParty) thirdParty: ThirdParty,
|
||||
@inject(TYPES.Config) config: Config,
|
||||
@inject(TYPES.Cache) cache: CacheProvider) {
|
||||
@inject(TYPES.KeyValueCache) cache: KeyValueCacheProvider) {
|
||||
this.youtube = thirdParty.youtube;
|
||||
this.youtubeKey = config.YOUTUBE_API_KEY;
|
||||
this.spotify = thirdParty.spotify;
|
||||
|
|
|
@ -12,7 +12,7 @@ type Options = {
|
|||
const futureTimeToDate = (time: Seconds) => new Date(new Date().getTime() + (time * 1000));
|
||||
|
||||
@injectable()
|
||||
export default class CacheProvider {
|
||||
export default class KeyValueCacheProvider {
|
||||
async wrap<T extends [...any[], Options], F>(func: (...options: any) => Promise<F>, ...options: T): Promise<F> {
|
||||
if (options.length === 0) {
|
||||
throw new Error('Missing cache options');
|
Loading…
Add table
Add a link
Reference in a new issue