Make media caching an option

This commit is contained in:
An Phan 2017-01-15 12:27:05 +08:00
parent d5556f4991
commit 991133045d
No known key found for this signature in database
GPG key ID: 05536BB4BCDC02A2
3 changed files with 11 additions and 0 deletions

View file

@ -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.

View file

@ -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();

View file

@ -115,4 +115,6 @@ return [
'affiliate_id' => '1000lsGu',
],
'cache_media' => env('CACHE_MEDIA', true),
];