From 13fb3a10ae964b0de13991df24ca740c632af78c Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Thu, 30 Jan 2025 16:59:33 +0100 Subject: [PATCH] Simplify department name retrieval logic in Redis class Replaced JSON decoding with direct object casting for department data, reducing unnecessary parsing overhead. This change ensures a more efficient and straightforward handling of the `get_department_name` function. --- services/nginx/app/classes/redis.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/nginx/app/classes/redis.php b/services/nginx/app/classes/redis.php index 2140ed1b..9635663b 100644 --- a/services/nginx/app/classes/redis.php +++ b/services/nginx/app/classes/redis.php @@ -105,12 +105,12 @@ class redis implements redis_i public function get_department_name(int $department_id): string|null { // Get the department name - $tmp_department = $this->get('department_' . $department_id); + $tmp_department = (object)$this->get('department_' . $department_id) ?? null; if ($tmp_department === 'IS_EMPTY_OR_NULL' || $tmp_department === null) { return null; } // Return the department name - return json_decode($tmp_department, true)->name; + return $tmp_department->name; } /**