Update StoryIndexService, improve redis compatability

pull/6142/head
Daniel Supernault 3 months ago
parent 32b1f26d69
commit dbba523031
No known key found for this signature in database
GPG Key ID: 23740873EE6F76A1

@ -190,7 +190,11 @@ class StoryIndexService
$pipe->hset($keyStory, 'view_count', (string) $viewCount);
$pipe->expire($keyStory, (int) $ttl);
if (config('database.redis.client') === 'predis') {
$pipe->zadd($keyAuth, [$sid => $score]);
} else {
$pipe->zadd($keyAuth, $score, $sid);
}
$pipe->sadd('story:active_authors', $author);
$pipe->expire($keyAuth, (int) ($ttl + 3600));
});
@ -234,7 +238,11 @@ class StoryIndexService
{
$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'];
}

Loading…
Cancel
Save