mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 20:17:24 +08:00
fix increase user seedbonus
This commit is contained in:
@@ -43,7 +43,7 @@ class CleanupRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
$args = [
|
$args = [
|
||||||
self::USER_SEED_BONUS_BATCH_KEY, self::USER_SEEDING_LEECHING_TIME_BATCH_KEY, self::TORRENT_SEEDERS_ETC_BATCH_KEY,
|
self::USER_SEED_BONUS_BATCH_KEY, self::USER_SEEDING_LEECHING_TIME_BATCH_KEY, self::TORRENT_SEEDERS_ETC_BATCH_KEY,
|
||||||
$uid, $uid, $torrentId, self::getHashKeySuffix(), self::getCacheKeyLifeTime()
|
$uid, $uid, $torrentId, self::getHashKeySuffix(), self::getCacheKeyLifeTime(), time(),
|
||||||
];
|
];
|
||||||
$result = $redis->eval(self::getAddRecordLuaScript(), $args, 3);
|
$result = $redis->eval(self::getAddRecordLuaScript(), $args, 3);
|
||||||
$err = $redis->getLastError();
|
$err = $redis->getLastError();
|
||||||
@@ -85,13 +85,16 @@ class CleanupRepository extends BaseRepository
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//update the batch key
|
//update the batch key
|
||||||
$newBatch = $batchKey . ":" . self::getHashKeySuffix();
|
//用户魔力部分不更新,避免用户保旧种汇报时间过长影响魔力增加
|
||||||
$lifeTime = self::getCacheKeyLifeTime();
|
if ($batchKey != self::USER_SEED_BONUS_BATCH_KEY) {
|
||||||
$redis->set($batchKey, $newBatch, ['ex' => $lifeTime]);
|
$newBatch = $batchKey . ":" . self::getHashKeySuffix();
|
||||||
$redis->hSetNx($newBatch, -1, 1);
|
$lifeTime = self::getCacheKeyLifeTime();
|
||||||
$redis->expire($newBatch, $lifeTime);
|
$redis->set($batchKey, $newBatch, ['ex' => $lifeTime]);
|
||||||
|
$redis->hSetNx($newBatch, -1, 1);
|
||||||
|
$redis->expire($newBatch, $lifeTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
$userSeedBonusDeadline = deadtime();
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$it = NULL;
|
$it = NULL;
|
||||||
$length = $redis->hLen($batch);
|
$length = $redis->hLen($batch);
|
||||||
@@ -100,21 +103,37 @@ class CleanupRepository extends BaseRepository
|
|||||||
$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
|
$redis->setOption(\Redis::OPT_SCAN, \Redis::SCAN_RETRY);
|
||||||
while($arr_keys = $redis->hScan($batch, $it, "*", self::$scanSize)) {
|
while($arr_keys = $redis->hScan($batch, $it, "*", self::$scanSize)) {
|
||||||
$delay = self::getDelay($batchKeyInfo['task_index'], $length, $page);
|
$delay = self::getDelay($batchKeyInfo['task_index'], $length, $page);
|
||||||
$idStr = implode(",", array_keys($arr_keys));
|
$toRemoveFields = $validFields = [];
|
||||||
$idRedisKey = self::IDS_KEY_PREFIX . Str::random();
|
foreach ($arr_keys as $field => $value) {
|
||||||
NexusDB::cache_put($idRedisKey, $idStr);
|
if ($batchKey == self::USER_SEED_BONUS_BATCH_KEY && $value < $userSeedBonusDeadline) {
|
||||||
$command = sprintf(
|
//dead, should remove
|
||||||
'cleanup --action=%s --begin_id=%s --end_id=%s --id_redis_key=%s --request_id=%s --delay=%s',
|
$toRemoveFields[] = $field;
|
||||||
$batchKeyInfo['action'], 0, 0, $idRedisKey, $requestId, $delay
|
} else {
|
||||||
);
|
$validFields[] = $field;
|
||||||
$output = executeCommand($command, 'string', true);
|
}
|
||||||
do_log(sprintf('output: %s', $output));
|
}
|
||||||
$count += count($arr_keys);
|
if (!empty($validFields)) {
|
||||||
|
$idStr = implode(",", $validFields);
|
||||||
|
$idRedisKey = self::IDS_KEY_PREFIX . Str::random();
|
||||||
|
NexusDB::cache_put($idRedisKey, $idStr);
|
||||||
|
$command = sprintf(
|
||||||
|
'cleanup --action=%s --begin_id=%s --end_id=%s --id_redis_key=%s --request_id=%s --delay=%s',
|
||||||
|
$batchKeyInfo['action'], 0, 0, $idRedisKey, $requestId, $delay
|
||||||
|
);
|
||||||
|
$output = executeCommand($command, 'string', true);
|
||||||
|
do_log(sprintf('output: %s', $output));
|
||||||
|
$count += count($validFields);
|
||||||
|
}
|
||||||
|
if (!empty($toRemoveFields)) {
|
||||||
|
$redis->hDel($batch, ...$toRemoveFields);
|
||||||
|
}
|
||||||
$page++;
|
$page++;
|
||||||
}
|
}
|
||||||
|
|
||||||
//remove this batch
|
//remove this batch
|
||||||
$redis->del($batch);
|
if ($batchKey != self::USER_SEED_BONUS_BATCH_KEY) {
|
||||||
|
$redis->del($batch);
|
||||||
|
}
|
||||||
$endTimestamp = time();
|
$endTimestamp = time();
|
||||||
do_log(sprintf("$logPrefix, [DONE], batch: $batch, count: $count, cost time: %d seconds", $endTimestamp - $beginTimestamp));
|
do_log(sprintf("$logPrefix, [DONE], batch: $batch, count: $count, cost time: %d seconds", $endTimestamp - $beginTimestamp));
|
||||||
}
|
}
|
||||||
@@ -136,7 +155,8 @@ class CleanupRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* USER_SEED_BONUS, USER_SEEDING_LEECHING_TIME, TORRENT_SEEDERS_ETC, uid, uid, torrentId, timeStr, cacheLifeTime
|
* USER_SEED_BONUS, USER_SEEDING_LEECHING_TIME, TORRENT_SEEDERS_ETC,
|
||||||
|
* uid, uid, torrentId, timeStr, cacheLifeTime, nowTimestamp
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -162,7 +182,7 @@ for k, v in pairs(batchList) do
|
|||||||
else
|
else
|
||||||
hashKey = ARGV[3]
|
hashKey = ARGV[3]
|
||||||
end
|
end
|
||||||
redis.call("HSETNX", batchKey, hashKey, 1)
|
redis.call("HSET", batchKey, hashKey, ARGV[6])
|
||||||
if isBatchKeyNew then
|
if isBatchKeyNew then
|
||||||
redis.call("EXPIRE", batchKey, ARGV[5])
|
redis.call("EXPIRE", batchKey, ARGV[5])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.10');
|
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.11');
|
||||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-23');
|
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-03-27');
|
||||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||||
|
|||||||
@@ -2163,7 +2163,7 @@ function mksizeint($bytes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function deadtime() {
|
function deadtime() {
|
||||||
global $anninterthree;
|
$anninterthree = (int)get_setting("main.anninterthree");
|
||||||
return time() - floor($anninterthree * 1.3);
|
return time() - floor($anninterthree * 1.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user