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
This commit is contained in:
parent
d7aeb1a89f
commit
b4e146fb60
5 changed files with 23 additions and 24 deletions
|
@ -1072,8 +1072,7 @@ default_user_preferences:
|
||||||
##
|
##
|
||||||
#extend_desc: false
|
#extend_desc: false
|
||||||
|
|
||||||
# redis_url: 127.0.0.1:6379
|
# 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
|
||||||
# redis_socket: /var/run/valkey/valkey.sock
|
|
||||||
# donation_url: "https://example.com/donate"
|
# donation_url: "https://example.com/donate"
|
||||||
# contact_url: "https://example.com/contact"
|
# contact_url: "https://example.com/contact"
|
||||||
# home_domain: "https://example.com/
|
# home_domain: "https://example.com/
|
||||||
|
|
21
shard.lock
21
shard.lock
|
@ -2,15 +2,15 @@ version: 2.0
|
||||||
shards:
|
shards:
|
||||||
ameba:
|
ameba:
|
||||||
git: https://github.com/crystal-ameba/ameba.git
|
git: https://github.com/crystal-ameba/ameba.git
|
||||||
version: 1.6.1
|
version: 1.6.4
|
||||||
|
|
||||||
athena-negotiation:
|
athena-negotiation:
|
||||||
git: https://github.com/athena-framework/negotiation.git
|
git: https://github.com/athena-framework/negotiation.git
|
||||||
version: 0.1.1
|
version: 0.1.5
|
||||||
|
|
||||||
backtracer:
|
backtracer:
|
||||||
git: https://github.com/sija/backtracer.cr.git
|
git: https://github.com/sija/backtracer.cr.git
|
||||||
version: 1.2.2
|
version: 1.2.4
|
||||||
|
|
||||||
db:
|
db:
|
||||||
git: https://github.com/crystal-lang/crystal-db.git
|
git: https://github.com/crystal-lang/crystal-db.git
|
||||||
|
@ -20,13 +20,14 @@ shards:
|
||||||
git: https://github.com/crystal-loot/exception_page.git
|
git: https://github.com/crystal-loot/exception_page.git
|
||||||
version: 0.4.1
|
version: 0.4.1
|
||||||
|
|
||||||
inotify:
|
|
||||||
git: https://github.com/petoem/inotify.cr.git
|
|
||||||
version: 1.0.3
|
|
||||||
http_proxy:
|
http_proxy:
|
||||||
git: https://github.com/mamantoha/http_proxy.git
|
git: https://github.com/mamantoha/http_proxy.git
|
||||||
version: 0.10.3
|
version: 0.10.3
|
||||||
|
|
||||||
|
inotify:
|
||||||
|
git: https://github.com/petoem/inotify.cr.git
|
||||||
|
version: 1.0.3
|
||||||
|
|
||||||
kemal:
|
kemal:
|
||||||
git: https://github.com/kemalcr/kemal.git
|
git: https://github.com/kemalcr/kemal.git
|
||||||
version: 1.6.0
|
version: 1.6.0
|
||||||
|
@ -35,10 +36,6 @@ shards:
|
||||||
git: https://github.com/will/crystal-pg.git
|
git: https://github.com/will/crystal-pg.git
|
||||||
version: 0.28.0
|
version: 0.28.0
|
||||||
|
|
||||||
pool:
|
|
||||||
git: https://github.com/ysbaddaden/pool.git
|
|
||||||
version: 0.2.4
|
|
||||||
|
|
||||||
protodec:
|
protodec:
|
||||||
git: https://github.com/iv-org/protodec.git
|
git: https://github.com/iv-org/protodec.git
|
||||||
version: 0.1.5
|
version: 0.1.5
|
||||||
|
@ -48,8 +45,8 @@ shards:
|
||||||
version: 0.4.1
|
version: 0.4.1
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
git: https://github.com/stefanwille/crystal-redis.git
|
git: https://github.com/jgaskins/redis.git
|
||||||
version: 2.9.1
|
version: 0.11.3
|
||||||
|
|
||||||
spectator:
|
spectator:
|
||||||
git: https://github.com/icy-arctic-fox/spectator.git
|
git: https://github.com/icy-arctic-fox/spectator.git
|
||||||
|
|
|
@ -25,7 +25,7 @@ dependencies:
|
||||||
github: athena-framework/negotiation
|
github: athena-framework/negotiation
|
||||||
version: ~> 0.1.1
|
version: ~> 0.1.1
|
||||||
redis:
|
redis:
|
||||||
github: stefanwille/crystal-redis
|
github: jgaskins/redis
|
||||||
inotify:
|
inotify:
|
||||||
github: petoem/inotify.cr
|
github: petoem/inotify.cr
|
||||||
version: 1.0.3
|
version: 1.0.3
|
||||||
|
|
|
@ -107,8 +107,8 @@ class Config
|
||||||
# Database configuration using 12-Factor "Database URL" syntax
|
# Database configuration using 12-Factor "Database URL" syntax
|
||||||
@[YAML::Field(converter: Preferences::URIConverter)]
|
@[YAML::Field(converter: Preferences::URIConverter)]
|
||||||
property database_url : URI = URI.parse("")
|
property database_url : URI = URI.parse("")
|
||||||
property redis_url : String?
|
@[YAML::Field(converter: Preferences::URIConverter)]
|
||||||
property redis_socket : String?
|
property redis_url : URI = URI.parse("")
|
||||||
# Use polling to keep decryption function up to date
|
# Use polling to keep decryption function up to date
|
||||||
property decrypt_polling : Bool = false
|
property decrypt_polling : Bool = false
|
||||||
# Used for crawling channels: threads should check all videos uploaded by a channel
|
# Used for crawling channels: threads should check all videos uploaded by a channel
|
||||||
|
|
|
@ -97,21 +97,24 @@ module Invidious::Database::Videos
|
||||||
end
|
end
|
||||||
|
|
||||||
class Redis_
|
class Redis_
|
||||||
@redis : Redis::PooledClient
|
@redis : Redis::Client
|
||||||
|
|
||||||
def initialize
|
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 "Video Cache: Using Redis compatible DB to store video cache"
|
||||||
LOGGER.info "Connecting to Redis compatible DB"
|
LOGGER.info "Connecting to Redis compatible DB"
|
||||||
if @redis.ping
|
# #ping method is not available in this Redis library
|
||||||
LOGGER.info "Connected to Redis compatible DB via unix domain socket at '#{CONFIG.redis_socket}'" if CONFIG.redis_socket
|
# https://github.com/jgaskins/redis/issues/53
|
||||||
LOGGER.info "Connected to Redis compatible DB via TCP socket at '#{CONFIG.redis_url}'" if CONFIG.redis_url
|
# 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
|
||||||
end
|
end
|
||||||
|
|
||||||
def set(video : Video, expire_time)
|
def set(video : Video, expire_time)
|
||||||
@redis.set(video.id, video.info.to_json, expire_time)
|
@redis.set(video.id, video.info.to_json, ex: expire_time)
|
||||||
@redis.set(video.id + ":time", video.updated, expire_time)
|
@redis.set(video.id + ":time", video.updated.to_s, ex: expire_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
def del(id : String)
|
def del(id : String)
|
||||||
|
|
Loading…
Add table
Reference in a new issue