Compare commits

...

3 commits

Author SHA1 Message Date
f4be08cf74
test: test
Some checks failed
Invidious CI / build (push) Failing after 51s
2025-04-13 02:27:21 -04:00
d7a632d51d
redis: replace lib by jgaskins/redis
https://github.com/jgaskins/redis

It's faster and in active development, old one gave me this using a TCP
connection:

test   5.94k (168.34µs) (±56.73%)  144B/op  fastest
test   5.11k (195.76µs) (±58.89%)  144B/op  fastest
test   5.48k (182.33µs) (±73.39%)  144B/op  fastest
test   3.42k (292.56µs) (±66.19%)  144B/op  fastest

meanwhile, the jgaskins/redis one gives:

test   6.96k (143.66µs) (±58.73%)  96.0B/op  fastest
test   6.36k (157.16µs) (±55.95%)  96.0B/op  fastest
test   7.06k (141.65µs) (±57.03%)  96.0B/op  fastest
2025-04-13 02:05:13 -04:00
d7aeb1a89f
minify-js: add missing subscribe_widget.js script 2025-04-13 00:39:07 -04:00
7 changed files with 29 additions and 15 deletions

View file

@ -52,5 +52,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
"release=1"

View file

@ -1072,8 +1072,7 @@ default_user_preferences:
##
#extend_desc: false
# redis_url: 127.0.0.1:6379
# redis_socket: /var/run/valkey/valkey.sock
# redis_url: redis://127.0.0.1:6379/0?initial_pool_size=1&max_pool_size=10&checkout_timeout=10&retry_attempts=2&retry_delay=0.5&max_idle_pool_size=50
# donation_url: "https://example.com/donate"
# contact_url: "https://example.com/contact"
# home_domain: "https://example.com/

View file

@ -7,6 +7,7 @@ ARG release
WORKDIR /invidious
COPY ./shard.yml ./shard.yml
COPY ./shard.lock ./shard.lock
RUN shards install --production
COPY ./src/ ./src/
@ -19,9 +20,17 @@ COPY ./scripts/ ./scripts/
COPY ./assets/ ./assets/
COPY ./videojs-dependencies.yml ./videojs-dependencies.yml
RUN crystal spec --warnings all \
--link-flags "-lxml2 -llzma"
RUN --mount=type=cache,target=/root/.cache/crystal if [[ "${release}" == 1 ]] ; then \
RUN crystal build ./scripts/minify-js.cr \
--release --mcpu=x86-64-v2 \
--static \
--link-flags "-lxml2 -llzma"; \
RUN crystal build ./scripts/fetch-player-dependencies.cr \
--release --mcpu=x86-64-v2 \
--static \
--link-flags "-lxml2 -llzma"; \
RUN if [[ "${release}" == 1 ]] ; then \
crystal build ./src/invidious.cr \
--release --mcpu=x86-64-v2 \
--static --warnings all \

View file

@ -61,6 +61,7 @@ files_to_minify = [
"playlist_widget.js",
"post.js",
"sse.js",
"subscribe_widget.js",
"themes.js",
"watch.js",
"player.js",

View file

@ -25,7 +25,7 @@ dependencies:
github: athena-framework/negotiation
version: ~> 0.1.1
redis:
github: stefanwille/crystal-redis
github: jgaskins/redis
inotify:
github: petoem/inotify.cr
version: 1.0.3

View file

@ -107,8 +107,8 @@ class Config
# Database configuration using 12-Factor "Database URL" syntax
@[YAML::Field(converter: Preferences::URIConverter)]
property database_url : URI = URI.parse("")
property redis_url : String?
property redis_socket : String?
@[YAML::Field(converter: Preferences::URIConverter)]
property redis_url : URI = URI.parse("")
# Use polling to keep decryption function up to date
property decrypt_polling : Bool = false
# Used for crawling channels: threads should check all videos uploaded by a channel

View file

@ -97,21 +97,24 @@ module Invidious::Database::Videos
end
class Redis_
@redis : Redis::PooledClient
@redis : Redis::Client
def initialize
@redis = Redis::PooledClient.new(unixsocket: CONFIG.redis_socket || nil, url: CONFIG.redis_url || nil)
@redis = Redis::Client.new(CONFIG.redis_url)
LOGGER.info "Video Cache: Using Redis compatible DB to store video cache"
LOGGER.info "Connecting to Redis compatible DB"
if @redis.ping
LOGGER.info "Connected to Redis compatible DB via unix domain socket at '#{CONFIG.redis_socket}'" if CONFIG.redis_socket
LOGGER.info "Connected to Redis compatible DB via TCP socket at '#{CONFIG.redis_url}'" if CONFIG.redis_url
# #ping method is not available in this Redis library
# https://github.com/jgaskins/redis/issues/53
# if @redis.ping
if @redis.run({"PING"}) == "PONG"
# LOGGER.info "Connected to Redis compatible DB via unix domain socket at '#{CONFIG.redis_socket}'" if CONFIG.redis_socket
LOGGER.info "Connected to Redis compatible DB at '#{CONFIG.redis_url}'" if CONFIG.redis_url
end
end
def set(video : Video, expire_time)
@redis.set(video.id, video.info.to_json, expire_time)
@redis.set(video.id + ":time", video.updated, expire_time)
@redis.set(video.id, video.info.to_json, ex: expire_time)
@redis.set(video.id + ":time", video.updated.to_s, ex: expire_time)
end
def del(id : String)