Skip to content

Кадников Николай Лаб. 1 Группа 6513#5

Open
Airfix982 wants to merge 5 commits intoitsecd:mainfrom
Airfix982:feature/cache
Open

Кадников Николай Лаб. 1 Группа 6513#5
Airfix982 wants to merge 5 commits intoitsecd:mainfrom
Airfix982:feature/cache

Conversation

@Airfix982
Copy link

ФИО: Кадников Николай
Номер группы: 6513
Номер лабораторной: 1
Номер варианта: 42
Краткое описание предметной области: Программный проект
Краткое описание добавленных фич: Добавлены сервис генерации и кэширование

@github-actions github-actions bot added In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование labels Feb 17, 2026
@github-actions github-actions bot requested a review from alxmcs February 17, 2026 10:48
Airfix982 and others added 2 commits February 19, 2026 15:23
…tead of usual ones, removed extra methods, added Redis exceptions handling, changed cors configuration, refactored ProgramProjectGeneratorService.cs - moved all the logic into new ProgramProjectCacheService.cs + small refactoring
@Airfix982 Airfix982 requested a review from alxmcs February 19, 2026 11:26
/// This class describes program project with customer, manager,
/// dates of start n end, budged and spent money.
/// </summary>
public record ProgramProject
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мб не заметил этого на прошлом ревью, но смысла объявлять этот класс record-ом нет никакого, так как никакими преимуществами рекордов ты в коде не пользуешься, зато заставляешь компилятор генерить дополнительный код

/// </summary>
public class ProgramProjectCacheService(RedisCacheService cs, Faker<ProgramProject> faker)
{
private RedisCacheService _cs = cs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Блин, ну назови это типа _casheService или _redis, _cs совсем нерепрезентативно звучит

Comment on lines +15 to +16
private RedisCacheService _cs = cs;
private Faker<ProgramProject> _faker = faker;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тебе не нужны эти приватные поля, компилятор сгенерирует их за тебя при использовании праймари конструктора, просто используй напрямую его входные параметры

/// Provides cached access to <see cref="ProgramProject"/> instances.
/// Generates a new project if it is not found in Redis.
/// </summary>
public class ProgramProjectCacheService(RedisCacheService cs, Faker<ProgramProject> faker)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Иметь две сущности, которые оканчиваются на *CacheService - крайне негуманно по отношению к гипотетическим коллегам, которые будут работать на одном проекте с тобой

Console.WriteLine(ex.Message);
}
ProgramProject newProject = _faker.Generate();
await _cs.SetAsync(key, newProject, TimeSpan.FromHours(12));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А на SetAsync кэша точно ничего не может пойти не так, и обработка исключений тут не нужна?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

In progress Код в процессе проверки Lab 1 Лабораторная №1. Кэширование

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments