작업을 스케줄(주기적으로 실행)하는데 사용가능
→ cache evict를 주기적으로 하기 위해 설정
@Configuration, @EnableScheduling
스케줄링
@Scheduled( fixedDelay 또는 fixedRate 또는 cron expression)
parameterizing schedule
scheduler는 기본적으로 싱글 스레드.
멀티스레드 설정도 가능함.
caching abstraction
https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/cache.html
cache abstraction으로 기존의 코드에 큰 영향을 주지 않으면서 캐시 적용할 수 있음
cache vs buffer
buffer : 느리고 빠른 객체 사이의 속도 조절을 위한 일시적인 저장소. data는 버퍼에 1번만 write, read됨
cache : 계산한(쓰여진) 값을 여러번 읽히도록 하는게 목적
사용
cache configuration
캐시 저장소 설정
cache declaration
캐싱할 메서드 설정, 정책 설정
declarative annotation based caching
@Cacheable
key
default key generator 있음.
custom key generator → 'key' attribute 사용 (SPEL 사용)
@Cacheable(value="books", key="T(someType).hash(#isbn)")
conditional caching
@Cacheable(value="book", condition="#name.length < 32")
@CachePut
update cached data
@CacheEvict
remove data from cache
@Caching
여러 캐싱 어노테이션 함께 쓸 때 묶어주는 역할
@EnableCaching
custom annotation으로 replace 가능
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Cacheable(value=“books”, key="#isbn")
public @interface SlowService {
}
configuring cache storage
ConcurrnetMap based cache (org.springframework.cache.concurrent package)
EhCache based cache (org.springframework.cache.ehcache package)
GemFire based cache ?