mirror of
https://git.nadeko.net/Fijxu/invidious.git
synced 2025-12-14 17:15:09 +00:00
feat(Database::Videos): built-in video cache and support for multiple caching backends
I did this to get rid of Redis compatible DBs and for speed purposes. This is considered experimental, but everything works fine from what I have tested. Here are some benchmarks using the built-in benchmark library of crystal: \# built-in release cache get 19.79M ( 50.54ns) (± 4.12%) 32.0B/op fastest cache insert 7.88k (126.86µs) (± 2.20%) 65.5kB/op fastest cache get 4.31k (232.11µs) (± 5.50%) 104kB/op fastest \# redis release cache get 22.27k ( 44.90µs) (± 6.40%) 264B/op fastest cache insert 4.74k (211.01µs) (± 4.72%) 65.7kB/op fastest cache get 2.51k (399.11µs) (±13.15%) 129kB/op fastest --- OP/s are way higher, and memory usage per call is lower, so it's a win win.
This commit is contained in:
@@ -217,7 +217,16 @@ class Config
|
||||
|
||||
property tokens_server : String = ""
|
||||
|
||||
property video_cache : Bool = true
|
||||
property video_cache : VideoCacheConfig
|
||||
|
||||
class VideoCacheConfig
|
||||
include YAML::Serializable
|
||||
|
||||
property enabled : Bool = true
|
||||
property backend : Int32 = 1
|
||||
# Max quantity of keys that can be held on the LRU cache
|
||||
property lru_max_size : Int32 = 18432 # ~512MB
|
||||
end
|
||||
|
||||
{% if flag?(:linux) %}
|
||||
property reload_config_automatically : Bool = true
|
||||
@@ -395,6 +404,16 @@ class Config
|
||||
end
|
||||
end
|
||||
|
||||
if config.video_cache.enabled
|
||||
if !config.video_cache.backend.in?(0, 1, 2)
|
||||
puts "Config: 'video_cache_storage', can only be:"
|
||||
puts "0 (PostgreSQL)"
|
||||
puts "1 (Redis compatible DB) (Default)"
|
||||
puts "2 (In memory LRU)"
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
return config
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user