feat: Add Video Cache compression

Video information from youtube always weight about ~60KB uncompressed.
When using Deflate to compress that information, it gets compressed down
to ~15KB, so now you will be able to store up to 4x entries more with
caching enabled.

For context, nadeko.net Invidious instance stores 54.7k keys, since we
also store the `time` in a different key associated to the video ID, the
real count of videos cached would be 27.3k. With compression enabled,
the Redis database will be able to store up to 4 times more videos in
cache, which is 109.2k videos cached.

Pretty cool huh.
This commit is contained in:
Fijxu
2025-10-16 17:09:38 -03:00
parent 24218dc5df
commit aa8b5cfd4b
3 changed files with 79 additions and 3 deletions

View File

@@ -238,6 +238,8 @@ class Config
property backend : Int32 = 1
# Max quantity of keys that can be held on the LRU cache
property lru_max_size : Int32 = 18432 # ~512MB
# Compress cache with Deflate
property compress : Bool = false
end
property check_backends_interval : Int32 = 30
@@ -453,6 +455,10 @@ class Config
puts "1 (Redis compatible DB) (Default)"
puts "2 (In memory LRU)"
end
if config.video_cache.compress && config.video_cache.backend == 0
puts "Video Cache compression can only be enabled when using backend 1 (Redis) or 2 (LRU)"
exit(1)
end
end
# Check if the socket configuration is valid