diff options
| author | Max Isom <[email protected]> | 2021-11-18 20:55:57 -0500 |
|---|---|---|
| committer | Max Isom <[email protected]> | 2021-11-18 20:55:57 -0500 |
| commit | 04c7e61fc076e2fa5ddf3d0faf6ebb73f4d52d82 (patch) | |
| tree | 71d1879e787b7c988939d963dbc4baa857171f5b /src/services | |
| parent | d805da906a1744c23e0b484b522b078102675770 (diff) | |
| download | muse-04c7e61fc076e2fa5ddf3d0faf6ebb73f4d52d82.tar.xz muse-04c7e61fc076e2fa5ddf3d0faf6ebb73f4d52d82.zip | |
Add FileCache model
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/get-songs.ts | 6 | ||||
| -rw-r--r-- | src/services/key-value-cache.ts (renamed from src/services/cache.ts) | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/services/get-songs.ts b/src/services/get-songs.ts index ba4401c..e7e3d5a 100644 --- a/src/services/get-songs.ts +++ b/src/services/get-songs.ts @@ -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; diff --git a/src/services/cache.ts b/src/services/key-value-cache.ts index 95c6731..7f1164d 100644 --- a/src/services/cache.ts +++ b/src/services/key-value-cache.ts @@ -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'); |
