From db7a17d39631721913cf99e3af0d749c0a5b229d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BE=E3=81=A3=E3=81=A1=E3=82=83=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Mon, 30 Oct 2023 00:27:20 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E3=81=AA=E3=81=A9?= =?UTF-8?q?=E3=81=ABKeyDB=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=20(MisskeyIO#195)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/docker_example.yml | 6 +++--- .devcontainer/devcontainer.yml | 6 +++--- .devcontainer/docker-compose.yml | 10 +++++----- .dockerignore | 1 + .github/workflows/test-backend.yml | 6 +++--- .github/workflows/test-frontend.yml | 6 +++--- .gitignore | 2 ++ chart/templates/Deployment.yml | 6 +++--- docker-compose.yml.example | 12 ++++++------ packages/backend/src/core/FeaturedService.ts | 10 +++++----- packages/backend/test/docker-compose.yml | 6 +++--- 11 files changed, 37 insertions(+), 34 deletions(-) diff --git a/.config/docker_example.yml b/.config/docker_example.yml index d457569167..b3d26ca5a6 100644 --- a/.config/docker_example.yml +++ b/.config/docker_example.yml @@ -72,7 +72,7 @@ dbReplications: false #───┘ Redis configuration └───────────────────────────────────── redis: - host: redis + host: keydb port: 6379 #family: 0 # 0=Both, 4=IPv4, 6=IPv6 #pass: example-pass @@ -80,7 +80,7 @@ redis: #db: 1 #redisForPubsub: -# host: redis +# host: keydb # port: 6379 # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 # #pass: example-pass @@ -88,7 +88,7 @@ redis: # #db: 1 #redisForJobQueue: -# host: redis +# host: keydb # port: 6379 # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 # #pass: example-pass diff --git a/.devcontainer/devcontainer.yml b/.devcontainer/devcontainer.yml index 824a046dc0..9e95ca4b41 100644 --- a/.devcontainer/devcontainer.yml +++ b/.devcontainer/devcontainer.yml @@ -72,7 +72,7 @@ dbReplications: false #───┘ Redis configuration └───────────────────────────────────── redis: - host: redis + host: keydb port: 6379 #family: 0 # 0=Both, 4=IPv4, 6=IPv6 #pass: example-pass @@ -80,7 +80,7 @@ redis: #db: 1 #redisForPubsub: -# host: redis +# host: keydb # port: 6379 # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 # #pass: example-pass @@ -88,7 +88,7 @@ redis: # #db: 1 #redisForJobQueue: -# host: redis +# host: keydb # port: 6379 # #family: 0 # 0=Both, 4=IPv4, 6=IPv6 # #pass: example-pass diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2809cd2ca4..ece9e8f113 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -15,15 +15,15 @@ services: - internal_network - external_network - redis: + keydb: restart: unless-stopped - image: redis:7-alpine + image: eqalpha/keydb:latest networks: - internal_network volumes: - - redis-data:/data + - keydb-data:/data healthcheck: - test: "redis-cli ping" + test: "keydb-cli ping" interval: 5s retries: 20 @@ -45,7 +45,7 @@ services: volumes: postgres-data: - redis-data: + keydb-data: networks: internal_network: diff --git a/.dockerignore b/.dockerignore index 1de0c7982b..8ecffe1c7f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,6 +11,7 @@ docker-compose.yml node_modules/ packages/*/node_modules redis/ +keydb/ files/ misskey-assets/ fluent-emojis/ diff --git a/.github/workflows/test-backend.yml b/.github/workflows/test-backend.yml index d7be15bd4f..06961ace19 100644 --- a/.github/workflows/test-backend.yml +++ b/.github/workflows/test-backend.yml @@ -17,14 +17,14 @@ jobs: services: postgres: - image: postgres:13 + image: postgres:15 ports: - 54312:5432 env: POSTGRES_DB: test-misskey POSTGRES_HOST_AUTH_METHOD: trust - redis: - image: redis:7 + keydb: + image: eqalpha/keydb:latest ports: - 56312:6379 diff --git a/.github/workflows/test-frontend.yml b/.github/workflows/test-frontend.yml index 4ea4ba4628..d7de19c659 100644 --- a/.github/workflows/test-frontend.yml +++ b/.github/workflows/test-frontend.yml @@ -56,14 +56,14 @@ jobs: services: postgres: - image: postgres:13 + image: postgres:15 ports: - 54312:5432 env: POSTGRES_DB: test-misskey POSTGRES_HOST_AUTH_METHOD: trust - redis: - image: redis:7 + keydb: + image: eqalpha/keydb:latest ports: - 56312:6379 diff --git a/.gitignore b/.gitignore index a66e527db0..f66d6e1344 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,7 @@ coverage !/.config/docker_example.env docker-compose.yml !/.devcontainer/docker-compose.yml +!/packages/backend/test/docker-compose.yml # misskey /build @@ -51,6 +52,7 @@ run.bat api-docs.json *.log /redis +/keydb *.code-workspace .DS_Store /files diff --git a/chart/templates/Deployment.yml b/chart/templates/Deployment.yml index d5dd14f59e..a6ea8b2160 100644 --- a/chart/templates/Deployment.yml +++ b/chart/templates/Deployment.yml @@ -27,7 +27,7 @@ spec: ports: - containerPort: 3000 - name: postgres - image: postgres:14-alpine + image: postgres:15-alpine env: - name: POSTGRES_USER value: "example-misskey-user" @@ -37,8 +37,8 @@ spec: value: "misskey" ports: - containerPort: 5432 - - name: redis - image: redis:alpine + - name: keydb + image: eqalpha/keydb:latest ports: - containerPort: 6379 volumes: diff --git a/docker-compose.yml.example b/docker-compose.yml.example index a0061c5c20..e4f8a7f167 100644 --- a/docker-compose.yml.example +++ b/docker-compose.yml.example @@ -6,12 +6,12 @@ services: restart: always links: - db - - redis + - keydb # - meilisearch depends_on: db: condition: service_healthy - redis: + keydb: condition: service_healthy ports: - "3000:3000" @@ -22,15 +22,15 @@ services: - ./files:/misskey/files - ./.config:/misskey/.config:ro - redis: + keydb: restart: always - image: redis:7-alpine + image: eqalpha/keydb:latest networks: - internal_network volumes: - - ./redis:/data + - ./keydb:/data healthcheck: - test: "redis-cli ping" + test: "keydb-cli ping" interval: 5s retries: 20 diff --git a/packages/backend/src/core/FeaturedService.ts b/packages/backend/src/core/FeaturedService.ts index 555a646cdc..0772dc689f 100644 --- a/packages/backend/src/core/FeaturedService.ts +++ b/packages/backend/src/core/FeaturedService.ts @@ -38,7 +38,7 @@ export class FeaturedService { redisTransaction.expire( `${name}:${currentWindow}`, (windowRange * 3) / 1000, - 'NX'); // "NX -- Set expiry only when the key has no expiry" = 有効期限がないときだけ設定 + ); await redisTransaction.exec(); } @@ -48,10 +48,10 @@ export class FeaturedService { const previousWindow = currentWindow - 1; const redisPipeline = this.redisClient.pipeline(); - redisPipeline.zrange( - `${name}:${currentWindow}`, 0, threshold, 'REV', 'WITHSCORES'); - redisPipeline.zrange( - `${name}:${previousWindow}`, 0, threshold, 'REV', 'WITHSCORES'); + redisPipeline.zrevrange( + `${name}:${currentWindow}`, 0, threshold, 'WITHSCORES'); + redisPipeline.zrevrange( + `${name}:${previousWindow}`, 0, threshold, 'WITHSCORES'); const [currentRankingResult, previousRankingResult] = await redisPipeline.exec().then(result => result ? result.map(r => r[1] as string[]) : [[], []]); const ranking = new Map(); diff --git a/packages/backend/test/docker-compose.yml b/packages/backend/test/docker-compose.yml index da6c01dda1..286a6607a5 100644 --- a/packages/backend/test/docker-compose.yml +++ b/packages/backend/test/docker-compose.yml @@ -1,13 +1,13 @@ version: "3" services: - redistest: - image: redis:7 + keydbtest: + image: eqalpha/keydb:latest ports: - "127.0.0.1:56312:6379" dbtest: - image: postgres:13 + image: postgres:15 ports: - "127.0.0.1:54312:5432" environment: