<?
namespace front\factory;
class Dictionaries
{
  static public function get_name_by_id( int $unit_id, $lang_id )
  {
    global $mdb;

    if ( !$unit_name = \Cache::fetch( "get_name_by_id:$unit_id:$lang_id", "dictionaries" ) )
    {
      $unit_name = $mdb -> get( 'pp_units_langs', 'text', [ 'AND' => [ 'unit_id' => $unit_id, 'lang_id' => $lang_id ] ] );
      \Cache::store( "get_name_by_id:$unit_id:$lang_id", $unit_name, 86400, "dictionaries" );
    }
    return $unit_name;
  }
}