Update: 2026-06-21 02:07:00
This commit is contained in:
@@ -140,18 +140,30 @@ try {
|
||||
|
||||
// تخزين الدين في الـ Redis لمدة 6 شهور (15552000 ثانية)
|
||||
try {
|
||||
$redis = new Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
$redisPass = getenv('REDIS_PASSWORD');
|
||||
if ($redisPass) $redis->auth($redisPass);
|
||||
$redis->setOption(Redis::OPT_PREFIX, 'siro:');
|
||||
$redisKey = "passenger_debt_" . $passenger_id;
|
||||
// إضافة الدين الجديد إلى الدين السابق إن وجد
|
||||
$currentDebt = (float) $redis->get($redisKey);
|
||||
$newDebt = $currentDebt + $negativeDebt;
|
||||
$redis->setex($redisKey, 15552000, $newDebt);
|
||||
$redisInstance = null;
|
||||
if (isset($redis) && $redis !== null) {
|
||||
$redisInstance = $redis;
|
||||
} else if (extension_loaded('redis')) {
|
||||
$localRedis = new Redis();
|
||||
$redisHost = getenv('REDIS_MAIN_HOST') ?: getenv('REDIS_HOST') ?: '127.0.0.1';
|
||||
$redisPort = (int)(getenv('REDIS_MAIN_PORT') ?: getenv('REDIS_PORT') ?: 6379);
|
||||
$redisPass = getenv('REDIS_MAIN_PASSWORD') ?: getenv('REDIS_MAIN_AUTH') ?: getenv('REDIS_PASSWORD') ?: getenv('REDIS_AUTH');
|
||||
if ($localRedis->connect($redisHost, $redisPort, 1.5)) {
|
||||
if ($redisPass) $localRedis->auth($redisPass);
|
||||
$localRedis->setOption(Redis::OPT_PREFIX, 'siro:');
|
||||
$redisInstance = $localRedis;
|
||||
}
|
||||
}
|
||||
|
||||
if ($redisInstance !== null) {
|
||||
$redisKey = "passenger_debt_" . $passenger_id;
|
||||
// إضافة الدين الجديد إلى الدين السابق إن وجد
|
||||
$currentDebt = (float) $redisInstance->get($redisKey);
|
||||
$newDebt = $currentDebt + $negativeDebt;
|
||||
$redisInstance->setex($redisKey, 15552000, $newDebt);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log("Redis Error: " . $e->getMessage());
|
||||
error_log("Redis Error in cancel_ride_by_driver: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user