package com.kamco.cd.training.menu.service;

import com.kamco.cd.training.menu.dto.MenuDto;
import com.kamco.cd.training.postgres.core.MenuCoreService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

// training 서버는 Redis 사용하지 않고 Spring Boot 메모리 캐시를 사용함
// => org.springframework.cache.annotation.Cacheable

@Service
@RequiredArgsConstructor
public class MenuService {
  private final MenuCoreService menuCoreService;

  @Cacheable("trainMenuFindAll")
  public List<MenuDto.Basic> getFindAll() {
    return menuCoreService.getFindAll();
  }

  /** 메모리 캐시 초기화 */
  @CacheEvict(value = "trainMenuFindAll", allEntries = true)
  public void refresh() {}
}
