Skip to content

Commit

Permalink
Limit cache db a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 25, 2024
1 parent 3127063 commit 29f28e8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions music_assistant/server/controllers/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def get(
return default

async def set(
self, key, data, checksum="", expiration=(86400 * 30), category: int = 0, base_key: str = ""
self, key, data, checksum="", expiration=(86400 * 7), category: int = 0, base_key: str = ""
) -> None:
"""Set data in cache."""
if not key:
Expand All @@ -139,7 +139,7 @@ async def set(
expires = int(time.time() + expiration)
memory_key = f"{category}/{base_key}/{key}"
self._mem_cache[memory_key] = (data, checksum, expires)
if (expires - time.time()) < 3600 * 4:
if (expires - time.time()) < 3600 * 12:
# do not cache items in db with short expiration
return
data = await asyncio.to_thread(json_dumps, data)
Expand Down

0 comments on commit 29f28e8

Please sign in to comment.