All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.patterncat.cache.component.LoggingCacheErrorHandler Maven / Gradle / Ivy

package cn.patterncat.cache.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.Cache;
import org.springframework.cache.interceptor.CacheErrorHandler;

/**
 * org/springframework/cache/interceptor/AbstractCacheInvoker.java
 * Created by cat on 2019-03-11.
 */
public class LoggingCacheErrorHandler implements CacheErrorHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingCacheErrorHandler.class);

    @Override
    public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) {
        LOGGER.error("Failed to get cache name = {}, key = {}, error={}", cache.getName(), key, exception.getMessage());
    }

    @Override
    public void handleCachePutError(RuntimeException exception, Cache cache, Object key, Object value) {
        LOGGER.error("Failed to put cache name = {}, key = {}, error={}", cache.getName(), key, exception.getMessage());
    }

    @Override
    public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) {
        LOGGER.error("Failed to evict cache name = {}, key = {}, error={}", cache.getName(), key, exception.getMessage());
    }

    @Override
    public void handleCacheClearError(RuntimeException exception, Cache cache) {
        LOGGER.error("Failed to clear cache name = {}, error={}", cache.getName(), exception.getMessage());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy