<?php

namespace App\Http\Services;

use App\Models\CountryModel;
use Illuminate\Support\Facades\Redis;

class CountryService
{
    public static function getCountryList()
    {
        $countryListCache = Redis::get('sem_country_list');
        if ($countryListCache) {
            return json_decode($countryListCache, true);
        }
        $result = CountryModel::select(['id', 'name'])->get()->toArray();
        Redis::set('sem_country_list', json_encode($result));
        Redis::expire('sem_country_list', 3600);
        return $result;
    }

}