diff --git a/src/invidious/helpers/handlers.cr b/src/invidious/helpers/handlers.cr index f2240691c..949eb3353 100644 --- a/src/invidious/helpers/handlers.cr +++ b/src/invidious/helpers/handlers.cr @@ -237,3 +237,16 @@ class HTTP::Client response end end + +struct Crystal::ThreadLocalValue(T) + @values = Hash(Thread, T).new + + def get(&block : -> T) + th = Thread.current + if !@values[th]? + @values[th] = yield + else + @values[th] + end + end +end