This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
kubectl get po | grep Evicted | awk '{print $1}' | xargs kubectl delete po | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cache:annotation-driven cache-manager="cacheManager" key-generator="cacheKeyGenerator"/> | |
<bean id="cacheKeyGenerator" class="com.meygam.cache.CacheKeyGenerator"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.lang3.builder.HashCodeBuilder; | |
import org.springframework.cache.interceptor.KeyGenerator; | |
public class CacheKeyGenerator implements KeyGenerator { | |
@Override | |
public Object generate(Object o, Method method, Object... objects) { | |
HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(); | |
hashCodeBuilder.append(method.getName()); | |
for (Object object : objects) { | |
hashCodeBuilder.append(object); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.cache.annotation.Cacheable; | |
. | |
. | |
@Cacheable("longCache") | |
public List<Product> getAllProducts(final int pageNumber) { | |
System.out.println("Inside DAO so cache did not get used"); | |
// TODO Auto-generated method stub | |
Query query = getEntityManager().createQuery("SELECT p FROM Product p"); | |
return query.setFirstResult(pageNumber * PAGE_SIZE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" updateCheck="false" maxBytesLocalHeap="1g" | |
maxBytesLocalOffHeap="4g" maxBytesLocalDisk="100g" > | |
<defaultCache maxElementsInMemory="5" eternal="false" | |
timeToIdleSeconds="20" timeToLiveSeconds="20" | |
overflowToDisk="false" diskPersistent="false" | |
memoryStoreEvictionPolicy="LRU"/> | |
<cache name="longCache" timeToLiveSeconds="10000"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"> | |
<property name="cacheManager" ref="ehcache"/> | |
</bean> | |
<!-- Ehcache library setup --> | |
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"> | |
<property name="configLocation" value="classpath:ehcache.xml"/> | |
</bean> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cache:annotation-driven cache-manager="cacheManager"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:cache="http://www.springframework.org/schema/cache" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd | |
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> | |
</beans> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>net.sf.ehcache</groupId> | |
<artifactId>ehcache-core</artifactId> | |
<version>2.3.1</version> | |
</dependency> |