incr($redisKey); // If this is the first request, set the expiry to 60 seconds if ($currentCount == 1) { $redis->expire($redisKey, 60); } jsonSuccess(["grid_id" => $grid_id, "count" => $currentCount], "Demand logged successfully"); } catch (Exception $e) { error_log("[log_demand.php] Redis error: " . $e->getMessage()); jsonError("Error logging demand"); } ?>