テストなどにKeyDBを使うように (MisskeyIO#195)

This commit is contained in:
まっちゃとーにゅ
2023-10-30 00:27:20 +09:00
committed by GitHub
parent 42bc2817be
commit db7a17d396
11 changed files with 37 additions and 34 deletions

View File

@@ -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<string, number>();

View File

@@ -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: