diff --git a/.env.example b/.env.example index eb233c7d..6d68fd02 100644 --- a/.env.example +++ b/.env.example @@ -82,6 +82,11 @@ OUTPUT_BIT_RATE=128 # environment, such a download will (silently) fail. ALLOW_DOWNLOAD=true +# If this is set to true, the query to get artist, album, and song information will be cached. +# This can give a boost to Koel's boot time, especially if your library is huge. +# However, the cache deserialization process can be memory sensitive, so if you encounter +# errors, try setting this to false. +CACHE_MEDIA=true # The variables below are Laravel-specific. # You can change them if you know what you're doing. Otherwise, just leave them as-is. diff --git a/app/Services/MediaCache.php b/app/Services/MediaCache.php index 979f548a..dd53a444 100644 --- a/app/Services/MediaCache.php +++ b/app/Services/MediaCache.php @@ -11,6 +11,10 @@ class MediaCache public function get() { + if (!config('koel.cache_media')) { + return Artist::orderBy('name')->with('albums', with('albums.songs'))->get(); + } + $data = Cache::get($this->keyName); if (!$data) { $data = Artist::orderBy('name')->with('albums', with('albums.songs'))->get(); diff --git a/config/koel.php b/config/koel.php index d9571bdd..806bb809 100644 --- a/config/koel.php +++ b/config/koel.php @@ -115,4 +115,6 @@ return [ 'affiliate_id' => '1000lsGu', ], + 'cache_media' => env('CACHE_MEDIA', true), + ];