package com.sequenceiq.cloudbreak.cache; import java.lang.reflect.Method; import org.springframework.cache.interceptor.SimpleKey; import org.springframework.stereotype.Service; import net.sf.ehcache.config.CacheConfiguration; @Service public class ResourceDefinitionCache implements CacheDefinition { private static final long MAX_ENTRIES = 1000L; @Override public CacheConfiguration cacheConfiguration() { CacheConfiguration cacheConfiguration = new CacheConfiguration(); cacheConfiguration.setName("resourceDefinitionCache"); cacheConfiguration.setMemoryStoreEvictionPolicy("LRU"); cacheConfiguration.setMaxEntriesLocalHeap(MAX_ENTRIES); return cacheConfiguration; } @Override public Object generate(Object target, Method method, Object... params) { if (params.length == 0) { return SimpleKey.EMPTY; } if (params.length == 1) { Object param = params[0]; if (param != null && !param.getClass().isArray()) { return param; } } return new SimpleKey(params); } @Override public Class type() { return Object.class; } }