update patch for redis patching

This commit is contained in:
Emilien Devos
2023-06-10 22:25:43 +02:00
parent 876376e988
commit 41b8608b7e
+13 -14
View File
@@ -1,19 +1,19 @@
From 31e7668fa3b32264830d71c94dc49e213a726f51 Mon Sep 17 00:00:00 2001
From 019134666dd15ace22d62456dffdae0ad2bb502f Mon Sep 17 00:00:00 2001
From: Emilien Devos <contact@emiliendevos.be>
Date: Sat, 11 Feb 2023 19:56:50 +0100
Date: Sat, 10 Jun 2023 22:21:38 +0200
Subject: [PATCH 1/1] use redis for video cache
---
shard.lock | 15 ++++++++++++---
shard.yml | 2 ++
src/invidious.cr | 9 ++++++++-
src/invidious.cr | 8 +++++++-
src/invidious/config.cr | 2 ++
src/invidious/database/videos.cr | 16 +++++++++++++---
src/invidious/videos.cr | 2 +-
6 files changed, 38 insertions(+), 8 deletions(-)
6 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/shard.lock b/shard.lock
index 235e4c25..8d61c101 100644
index 235e4c25..385174da 100644
--- a/shard.lock
+++ b/shard.lock
@@ -1,5 +1,9 @@
@@ -43,7 +43,7 @@ index 235e4c25..8d61c101 100644
+ redis:
+ git: https://github.com/stefanwille/crystal-redis.git
+ version: 2.8.3
+ version: 2.9.1
+
spectator:
git: https://github.com/icy-arctic-fox/spectator.git
@@ -69,7 +69,7 @@ index 7ee0bb2a..97cc35e9 100644
development_dependencies:
spectator:
diff --git a/src/invidious.cr b/src/invidious.cr
index d4f8e0fb..73219d07 100644
index 27c4775e..79e5a8dd 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -31,6 +31,7 @@ require "xml"
@@ -80,9 +80,9 @@ index d4f8e0fb..73219d07 100644
require "./invidious/database/*"
require "./invidious/database/migrations/*"
@@ -59,7 +60,13 @@ alias IV = Invidious
CONFIG = Config.load
HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32)
@@ -61,7 +62,12 @@ CONFIG = Config.load
HMAC_KEY_CONFIGURED = CONFIG.hmac_key != nil
HMAC_KEY = CONFIG.hmac_key || Random::Secure.hex(32)
-PG_DB = DB.open CONFIG.database_url
+PG_DB = DB.open CONFIG.database_url
@@ -91,7 +91,6 @@ index d4f8e0fb..73219d07 100644
+if REDIS_DB.ping
+ puts "Connected to redis"
+end
+
ARCHIVE_URL = URI.parse("https://archive.org")
LOGIN_URL = URI.parse("https://accounts.google.com")
PUBSUB_URL = URI.parse("https://pubsubhubbub.appspot.com")
@@ -149,10 +148,10 @@ index 695f5b33..776ef5b1 100644
end
end
diff --git a/src/invidious/videos.cr b/src/invidious/videos.cr
index 436ac82d..6524d131 100644
index 0038a97a..e652e6d6 100644
--- a/src/invidious/videos.cr
+++ b/src/invidious/videos.cr
@@ -350,7 +350,7 @@ def get_video(id, refresh = true, region = nil, force_refresh = false)
@@ -355,7 +355,7 @@ def get_video(id, refresh = true, region = nil, force_refresh = false)
video.schema_version != Video::SCHEMA_VERSION # cache control
begin
video = fetch_video(id, region)
@@ -162,5 +161,5 @@ index 436ac82d..6524d131 100644
Invidious::Database::Videos.delete(id)
raise ex
--
2.39.1
2.40.1