Merge pull request #6142 from pixelfed/staging

Update StoryIndexService, improve redis compatability
pull/6163/head
(dan)iel (sup)ernault 3 months ago committed by GitHub
commit bd9026a0bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -190,7 +190,11 @@ class StoryIndexService
$pipe->hset($keyStory, 'view_count', (string) $viewCount); $pipe->hset($keyStory, 'view_count', (string) $viewCount);
$pipe->expire($keyStory, (int) $ttl); $pipe->expire($keyStory, (int) $ttl);
$pipe->zadd($keyAuth, [$sid => $score]); if (config('database.redis.client') === 'predis') {
$pipe->zadd($keyAuth, [$sid => $score]);
} else {
$pipe->zadd($keyAuth, $score, $sid);
}
$pipe->sadd('story:active_authors', $author); $pipe->sadd('story:active_authors', $author);
$pipe->expire($keyAuth, (int) ($ttl + 3600)); $pipe->expire($keyAuth, (int) ($ttl + 3600));
}); });
@ -234,7 +238,11 @@ class StoryIndexService
{ {
$lockKey = $this->rebuildLockKey(); $lockKey = $this->rebuildLockKey();
if (! Redis::set($lockKey, '1', 'EX', self::REBUILD_LOCK_TTL, 'NX')) { $lockAcquired = config('database.redis.client') === 'predis'
? Redis::set($lockKey, '1', 'EX', self::REBUILD_LOCK_TTL, 'NX')
: Redis::set($lockKey, '1', ['ex' => self::REBUILD_LOCK_TTL, 'nx' => true]);
if (! $lockAcquired) {
return ['status' => 'already_rebuilding', 'message' => 'Index rebuild already in progress']; return ['status' => 'already_rebuilding', 'message' => 'Index rebuild already in progress'];
} }

Loading…
Cancel
Save