package com.caliverse.admin.domain.cache;

import com.caliverse.admin.domain.datacomponent.MetaDataFileLoader;
import com.caliverse.admin.domain.request.LogGenericRequest;
import com.caliverse.admin.logs.logservice.businesslogservice.BusinessLogGenericService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@EnableCaching(proxyTargetClass = true)
public class CommonCacheHandler {
    @Autowired
    private BusinessLogGenericService businessLogGenericService;

    @Cacheable(value = "businessLogCount", keyGenerator = "logCountKeyGenerator")
    public Integer getLogCount(LogGenericRequest logGenericRequest) {
        log.info("Cache MISS - Executing actual DB query for count");
        return businessLogGenericService.getRawLogCount(logGenericRequest);
    }
}
