<?php

declare(strict_types=1);

\tts\main\registry::get('di')->register('cache', function(array $args) {
  $servers = \tts\main\configure::get('cache', 'servers');

  if (isset($args[0])) {
    $db_no = $args[0];
  } else {
    \tts\main\configure::get('cache', 'selected_db_no');
  }

  $auth = \tts\main\configure::get('cache', 'auth_password');
  return new \tts\services\cache\redis_db($servers, $db_no, $auth);
});
