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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user