๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Redis

์ฝ”๋“œ๋กœ ์•Œ์•„๋ณด๋Š” Spring Data Redis์˜ @Cacheable ๋™์ž‘ ์›๋ฆฌ์™€ ํŠธ๋žœ์žญ์…˜์—์„œ @CachePut/@CacheEvict ์‹คํ–‰ ์‹œ์ 

๊ธ€์˜ ๋ชฉํ‘œ

Spring Data Redis์—์„œ @Cacheable ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•˜๊ณ , ์บ์‹œ ๋ฏธ์Šค(Cache miss)๋กœ ์ธํ•ด ๋ฐ˜ํ™˜๊ฐ’์ด ์บ์‹œ์— ์ €์žฅ๋˜๋Š” ๊ณผ์ •. ๊ทธ๋ฆฌ๊ณ , @Transactional๊ณผ ํ•จ๊ป˜ @CachePut/@CacheEvict๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ @CachePut/@CacheEvict๊ฐ€ ์–ธ์ œ ์‹คํ–‰๋˜๋Š”์ง€๋ฅผ ๋‚ด๋ถ€ ๊ตฌํ˜„์„ ํ†ตํ•ด ์•„๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ์ž…๋‹ˆ๋‹ค.

 

๋ณธ ๊ธ€์€ RedisCache์— ํ•œ์ •๋œ ๋‚ด์šฉ์ž„์„ ๋ฏธ๋ฆฌ ์•Œ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค.

 

Spring Cache ์ถ”์ƒํ™” ๊ตฌ์กฐ

Spring Cache๋Š” Cache ์ธํ„ฐํŽ˜์ด์Šค์™€ CacheManager ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ์ถ”์ƒํ™”๋ฉ๋‹ˆ๋‹ค

This abstraction is materialized by the org.springframework.cache.Cache and org.springframework.cache.CacheManager interfaces.

 

Cache ์ธํ„ฐํŽ˜์ด์Šค

Cache ๋Š” Spring ์ด ์ง€์›ํ•˜๋Š” ์—ฌ๋Ÿฌ Cache ๊ตฌํ˜„์ฒด๋ฅผ ์ถ”์ƒํ™”ํ•œ ์ธํ„ฐํŽ˜์ด์Šค๋กœ Redis,Caffeine๋“ฑ ๋‹ค์–‘ํ•œ ์บ์‹œ๋ฅผ ์†์‰ฝ๊ฒŒ ๊ต์ฒดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Cache์—๋Š” get(), evict(), put() ๋“ฑ์˜ ๋ฉ”์„œ๋“œ๊ฐ€ ์žˆ์œผ๋ฉฐ, ์ด๋Š” ๊ฐ๊ฐ @Cacheable, @CacheEvict, @CachePut ์–ด๋…ธํ…Œ์ด์…˜๊ณผ ๋งค์นญ๋˜๋„๋ก ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

Cache ์ธํ„ฐํŽ˜์ด์Šค์™€ ๊ทธ ๊ตฌํ˜„์ฒด๋“ค

 

CacheManager ์ธํ„ฐํŽ˜์ด์Šค

CacheManager ๋Š” ์ด๋Ÿฌํ•œ Cache ๋“ค์„ ๊ด€๋ฆฌํ•˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค์ž…๋‹ˆ๋‹ค.

  • getCache(name) : ํŠน์ • ์บ์‹œ ๊ฐ€์ ธ์˜ค๊ธฐ
    • AbstractCacheManager ๋Š” getCache ์—์„œ Cache ๊ฐ€ ์—†์„๊ฒฝ์šฐ, Cache ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋„๋ก ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ ,  RedisCacheManager ๊ฐ€  AbstractCacheManager ๋ฅผ ์ƒ์†๋ฐ›๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. 
  • getCacheNames() : ์บ์‹œ ๋ชฉ๋ก ์กฐํšŒํ•˜๊ธฐ

CacheManager ์ธํ„ฐํŽ˜์ด์Šค์™€ ๊ทธ ๊ตฌํ˜„์ฒด๋“ค

 

์ด ์ค‘, TransactionAwareCacheManagerProxy ๊ฐ€ ํ˜ธ์ถœํ•˜๋Š” TransactionAwareCacheDecorator.class ๋ฅผ ํ†ตํ•ด @Transactional ์—์„œ @CacheEvict/Put์˜ ์‹คํ–‰ ์‹œ์ ์„ ์•Œ์•„๋ณด๊ณ , RedisCacheManager.class ๋ฅผ ํ†ตํ•ด @Cacheable ๋™์ž‘ ์›๋ฆฌ๋ฅผ ์•Œ์•„๊ฐ€ ๋ด…๋‹ˆ๋‹ค.

 

RedisCacheManager

RedisCacheManager๋Š” Spring Data Redis ์˜์กด์„ฑ์„ ํฌํ•จํ•  ๊ฒฝ์šฐ ์ œ๊ณต๋˜๋Š” ๊ธฐ๋ณธ ์บ์‹œ ๋งค๋‹ˆ์ €์ž…๋‹ˆ๋‹ค.

package org.springframework.data.redis.cache; // RedisCacheManager ์œ„์น˜

 

RedisCachManager ์˜ ์ฃผ์š” ์†์„ฑ๋“ค์„ ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

public class RedisCacheManager extends AbstractTransactionSupportingCacheManager {

    protected static final boolean DEFAULT_ALLOW_RUNTIME_CACHE_CREATION = true;
    private final boolean allowRuntimeCacheCreation; // ๊ธฐ๋ณธ๊ฐ’์€ true ์ž…๋‹ˆ๋‹ค.
    private final RedisCacheConfiguration defaultCacheConfiguration;
    private final RedisCacheWriter cacheWriter;
    private final Map<String, RedisCacheConfiguration> initialCacheConfiguration;

 

1. RedisCacheConfiguration defaultCacheConfiguration

  • ๊ธฐ๋ณธ ๊ฐ’
    • TTL(๋งŒ๋ฃŒ ์‹œ๊ฐ„) ์—†์Œ
    • ์บ์‹œ ๊ฐ’์— null ํ—ˆ์šฉ
    • key์˜ prefix๋Š” ํ—ˆ์šฉ(default prefix ๋Š” Cache Key์— "::" ๋ฅผ ๋ถ™์ž…๋‹ˆ๋‹ค.)
    • key ์ง๋ ฌํ™”์— ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ฒด : StringRedisSerializer
    • value ์ง๋ ฌํ™”์— ์‚ฌ์šฉํ•˜๋Š” ๊ฐ์ฒด : JdkSerializationRedisSerializer
    • DefaultFormattingConversionService ์€ JSR-354 Money & Currency and JSR-310 Date-Time ์™€ ๊ด€๋ จ๋˜๋‹ˆ, ๋‚ ์งœ/์‹œ๊ฐ„/ํ™”ํ์— ๊ด€๋ จ์žˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

2. RedisCacheWriter

RedisCacheWriter๋Š” Redis์— ๋Œ€ํ•œ ์ €์ˆ˜์ค€ ๋ช…๋ น์–ด ์‹คํ–‰์„ ๋‹ด๋‹นํ•˜๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค.

RedisCacheWriter provides low-level access to Redis commands (SET, SETNX, GET, EXPIRE,...) used for caching.
class DefaultRedisCacheWriter implements RedisCacheWriter {

    private static final boolean REACTIVE_REDIS_CONNECTION_FACTORY_PRESENT = ClassUtils
          .isPresent("org.springframework.data.redis.connection.ReactiveRedisConnectionFactory", null);

    private final BatchStrategy batchStrategy;
    private final CacheStatisticsCollector statistics;
    private final Duration sleepTime;
    private final RedisConnectionFactory connectionFactory;
    private final TtlFunction lockTtl;
    private final AsyncCacheWriter asyncCacheWriter;

์—ญ์‹œ Redis์— ๋Œ€ํ•œ ๋ช…๋ น์–ด๋ฅผ ์ „์†กํ•˜๊ธฐ ์œ„ํ•ด RedisConnectionFactory ๋ฅผ ํ•„๋“œ๋กœ ๊ฐ–๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. RedisConnectionFactory ์— ๋Œ€ํ•œ ์„ค๋ช…์€ 'RedisTemplate ๋‚ด๋ถ€ ํƒ๊ตฌ: Spring Data Redis๋Š” Lettuce๋ฅผ ์–ด๋–ป๊ฒŒ ์ถ”์ƒํ™”ํ–ˆ๋Š”๊ฐ€?' ๋ฅผ ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”.

 

๊ทธ ์™ธ์—๋„, ์บ์‹œ ํžˆํŠธ/๋ฏธ์Šค ํ†ต๊ณ„ ์ˆ˜์ง‘ ๋‹ด๋‹น์ธ CacheStatisticsCollector๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๊ฐ„๋‹จํ•˜๊ฒŒ ์ •๋ฆฌํ•˜์ž๋ฉด RedisCacheManager ๊ฐ€ TTL๋งŒ๋ฃŒ, ์ง๋ ฌํ™” ๋ฐฉ์‹ ๋“ฑ์„ ์ง€์ •ํ•˜๋Š” ์—ญํ• , RedisWriter ๋Š” ๋ ˆ๋””์Šค ๋ช…๋ น์–ด ์‹คํ–‰ํ•˜๋Š” ์—ญํ• , RedisConnectionFactory ๋Š” ์ด๋Ÿฌํ•œ ๋ช…๋ น์–ด๋“ค์„ Redis ์— ๋ณด๋‚ด๋Š” ์—ญํ• ์ด ๋ฉ๋‹ˆ๋‹ค.

 

@Cacheable ๋™์ž‘ ๊ณผ์ •

@EnableCaching ์€ ์บ์‹ฑ์— ํ•„์š”ํ•œ Spring Component ๋“ค์„ ๋“ฑ๋กํ•˜๋Š” ์ฑ…์ž„์„ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค๋ฉด, @Cacheable์ด ์„ ์–ธ๋œ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ, ์บ์‹ฑ ๋กœ์ง์„ ๊ฐ€๋กœ์ฑ„์„œ(intercept) ์‹คํ–‰ํ•˜๋Š” CacheInterceptor๋ฅผ ํ”„๋ก์‹œ(proxy)๋กœ ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.

In both of the scenarios above, @EnableCaching and <cache:annotation-driven/> are responsible for registering the necessary Spring components that power annotation-driven cache management, such as the CacheInterceptor and the proxy- or AspectJ-based advice that weaves the interceptor into the call stack when @Cacheable methods are invoked.
- @EnableCaching Javadoc ์ผ๋ถ€

 

@Cacheable ํ˜ธ์ถœ ์‹œ, ํ˜ธ์ถœ ์ˆœ์„œ

1. @Cacheable ์„ ํ˜ธ์ถœํ•˜๋ฉด CacheInterceptor ๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

2. CacheInterceptor ๋Š” CacheAspectSupport ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ , CacheAspectSupport ๋Š” findCachedValue() โ†’ findInCaches() ํ†ตํ•ด Cache ๋ฅผ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.(์—ฌ๊ธฐ์„œ๋Š” RedisCache์ž…๋‹ˆ๋‹ค.)

3. ์กฐํšŒํ•œ Cache ๋กœ findInCaches() ์—์„œ doGet( ) ์„ ํ†ตํ•ด ์บ์‹œ์˜ Key๋กœ Value๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค ํ•ฉ๋‹ˆ๋‹ค.

CacheAspectSupport ์˜ findInCaches() ๋‚ด๋ถ€ ๊ตฌํ˜„

4. doGet( ) ์„ ๋”ฐ๋ผ๊ฐ€๋ณด๋ฉด RedisCache ๊ฐ€ get( ) ๋ฉ”์„œ๋“œ๊ฐ€ ํ˜ธ์ถœ๋ฉ๋‹ˆ๋‹ค.

5. get( ) ์€ RedisWriter โ†’ RedisConnectionFactory ๋ฅผ ๊ฑฐ์ณ Redis์—์„œ Key์— ๋Œ€ํ•œ Value์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค.

6. ๋งŒ์•ฝ Value ๊ฐ€ ์—†๋‹ค๋ฉด getSynchronized() ์€ ReentrantLock ์„ ์‚ฌ์šฉํ•ด ๋™๊ธฐํ™” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ณ , loadCacheValue()๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์ƒˆ Value๋ฅผ Redis ์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

7. loadCacheValue ๊ณผ์ •์—์„œ put( ) ์ด ์‹คํ–‰๋˜๋ฉฐ, ์ตœ์ข…์ ์œผ๋กœ Redis์— ์ƒˆ๋กœ์šด Key-Value ๊ฐ€ ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.

RedisCache ์˜ get( )

๊ฒฐ๋ก 

  • @Cacheable ํ˜ธ์ถœ ์‹œ, ํ•ด๋‹น ํ‚ค(Key)์— ๋Œ€ํ•œ ๊ฐ’(Value)์ด ์บ์‹œ์— ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด Redis์— ์ƒˆ๋กœ์šด ๊ฐ’์ด ์ €์žฅ๋ฉ๋‹ˆ๋‹ค. ์ด ๊ณผ์ •์€ Thread-safeํ•˜๊ฒŒ ์ด๋ฃจ์–ด์ง‘๋‹ˆ๋‹ค.
    • ์ฆ‰, @Cacheable ์„ ๋™์‹œ์— 3๋ฒˆ ํ˜ธ์ถœํ•ด๋„ ๋‚ด๋ถ€์ ์œผ๋กœ ๋™๊ธฐํ™” ๋˜์–ด ์ •์ƒ์ ์œผ๋กœ 3๋ฒˆ๋‹ค ํ˜ธ์ถœ๋œ๋‹ค.(ํ˜ธ์ถœ ์ˆ˜ ๋งŒํผ counting ๋œ๋‹ค๊ณ  ์ดํ•ดํ•˜์‹œ๋ฉด ์‰ฌ์šธ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.)
  • @Cacheable(sync=true) ์˜ต์…˜์€ ์—ฌ๋Ÿฌ ์Šค๋ ˆ๋“œ๊ฐ€ ๋™์ผํ•œ ํ‚ค์— ๋Œ€ํ•ด ๊ฐ’์„ ์š”์ฒญํ•˜๋”๋ผ๋„ ์˜ค์ง ํ•˜๋‚˜์˜ ์Šค๋ ˆ๋“œ๋งŒ ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•˜๋ฉฐ, ๋‚˜๋จธ์ง€๋Š” ํ•ด๋‹น ์ž‘์—…์ด ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๋Œ€๊ธฐํ•œ๋‹ค. ๋‹ค๋งŒ, ์“ฐ๋ ˆ๋“œ๊ฐ€ ๋Œ€๊ธฐ(Blocking) ๋˜๋‹ˆ ์บ์‹œ ๋ฏธ์Šค๊ฐ€ ์ž์ฃผ ์ผ์–ด๋‚˜์ง€ ์•Š์•„์•ผ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

@CachePut / @CacheEvict์™€ @Transactional์˜ ๋™์ž‘ ๊ด€๊ณ„

Spring์—์„œ @CachePut๊ณผ @CacheEvict๋ฅผ @Transactional๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ, ํŠธ๋žœ์žญ์…˜๊ณผ ํ•จ๊ป˜ ์ˆ˜ํ–‰๋ ์ง€ ์—ฌ๋ถ€๋Š” TransactionAwareCacheDecorator ํด๋ž˜์Šค์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Cache decorator which synchronizes its put, evict and clear operations with Spring-managed transactions (through Spring's TransactionSynchronizationManager), performing the actual cache put/evict/clear operation only in the after-commit phase of a successful transaction. If no transaction is active, put, evict and clear operations will be performed immediately, as usual
- TransactionAwareCacheDecorator ์˜ Javadoc

 

ํ•ด๋‹น Javadoc์„ ํ™•์ธํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋™์ž‘ ๋ฐฉ์‹์ด ์ •์˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

ํŠธ๋žœ์žญ์…˜์ด ํ™œ์„ฑํ™”๋œ ๊ฒฝ์šฐ

  • put(์ €์žฅ), evict(์ œ๊ฑฐ), clear(์ „์ฒด ์‚ญ์ œ) ์—ฐ์‚ฐ์ด ์ฆ‰์‹œ ์‹คํ–‰๋˜์ง€ ์•Š๊ณ  ๋Œ€๊ธฐํ•œ๋‹ค.
  • ํŠธ๋žœ์žญ์…˜์ด ์„ฑ๊ณต์ ์œผ๋กœ ์ปค๋ฐ‹(commit)๋œ ํ›„, after-commit ๋‹จ๊ณ„์—์„œ ์—ฐ์‚ฐ์ด ์ˆ˜ํ–‰๋œ๋‹ค.
  • ์ฆ‰, ํŠธ๋žœ์žญ์…˜์ด ๋กค๋ฐฑ(rollback)๋˜๋ฉด ์บ์‹œ ์ž‘์—…๋„ ์‹คํ–‰๋˜์ง€ ์•Š๋Š”๋‹ค.

ํŠธ๋žœ์žญ์…˜์ด ์—†๋Š” ๊ฒฝ์šฐ

  • put, evict, clear ์—ฐ์‚ฐ์ด ์ฆ‰์‹œ ์‹คํ–‰๋œ๋‹ค.
  • ์ผ๋ฐ˜์ ์ธ ์บ์‹œ ๋™์ž‘๊ณผ ๋™์ผํ•จ.
  •  

Javadoc ์—์„œ ์„ค๋ช…ํ•˜๋Š” ์ฝ”๋“œ๋กœ TransactionAwareCacheDecorator ์˜ put ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค. this.target ์€ Cache ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋ฉฐ, afterCommit ์ž„์„ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

TransactionAwareCacheDecorator ์˜ put ๋ฉ”์„œ๋“œ

์œ„ ๊ธฐ๋Šฅ์„ ํ™œ์„ฑํ™” ํ•˜๋ ค๋ฉด CacheManager ๋ฅผ ๋นˆ์œผ๋กœ ๋“ฑ๋กํ•  ๋•Œ, transactionAware( ) ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

/**
 * Enable {@link RedisCache}s to synchronize cache put/evict operations with ongoing Spring-managed transactions.
 * @return this {@link RedisCacheManagerBuilder}.
 */
public RedisCacheManagerBuilder transactionAware() {
    this.enableTransactions = true;
    return this;
}

 

๋งˆ์น˜๋ฉฐ

์ด๋ฒˆ ๊ธ€์—์„œ๋Š” Redis์˜ ์ง๋ ฌํ™” ๋ฐฉ์‹, ๋น„๋™๊ธฐ ์š”์ฒญ ์ฒ˜๋ฆฌ, Redis ์•„ํ‚คํ…์ฒ˜์™€ ๊ฐ™์€ ๋ถ€๋ถ„์€ ๋‹ค๋ฃจ์ง€ ์•Š๊ณ , Spring์˜ ์บ์‹œ ์ถ”์ƒํ™”์— ์ดˆ์ ์„ ๋งž์ถฐ ์‚ดํŽด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

๊ฐ€๋”์€ ์ด๋ ‡๊ฒŒ๊นŒ์ง€ ๋‚ด๋ถ€ ๊ตฌํ˜„์„ ๊นŠ์ด ํŒŒ๊ณ ๋“ค ํ•„์š”๊ฐ€ ์žˆ์„๊นŒ? ํ•˜๋Š” ์ƒ๊ฐ์ด ๋“ค๊ธฐ๋„ ํ•˜์ง€๋งŒ, ์ง์ ‘ ํ•˜๋‚˜ํ•˜๋‚˜ ๋”ฐ๋ผ๊ฐ€๋‹ค ๋ณด๋ฉด ํฅ๋ฏธ๋กญ๊ธฐ๋„ ํ•˜๊ณ , ๋‹จ์ˆœํžˆ Javadoc์„ ์ฝ๋Š” ๊ฒƒ๋ณด๋‹ค ํ›จ์”ฌ ๋งŽ์€ ๊ฒƒ์„ ๋ฐฐ์šธ ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๋ฌด์—‡๋ณด๋‹ค ์‹œ๊ฐ„์ด ์ถฉ๋ถ„ ํ•ฉ๋‹ˆ๋‹ค..ใ…Ž

 

ํŠนํžˆ ์ด๋ฒˆ ๊ณผ์ •์—์„œ ReentrantLock ์ด ๋“ฑ์žฅํ–ˆ๋Š”๋ฐ, ๋งŒ์•ฝ ์ด ๊ฐœ๋…์„ ๋ชฐ๋ž๋‹ค๋ฉด ์ฝ”๋“œ๋ฅผ ์ฝ๋˜ ๋„์ค‘์— ์ดํ•ด๊ฐ€ ์–ด๋ ค์›Œ ํฌ๊ธฐํ–ˆ์„์ง€๋„ ๋ชจ๋ฆ…๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด Java ์™€ CS ์ง€์‹์ด ์™œ ์ค‘์š”ํ•œ์ง€ ๋‹ค์‹œ ํ•œ ๋ฒˆ ๊ณต๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

 

์ด๋ ‡๊ฒŒ ๊ธฐ์ˆ ์˜ ๋‚ด๋ถ€ ๊ตฌํ˜„์„ ๋ถ„์„ํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด ์‚ฌ์šฉ ์ค‘ ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ๋„ ๋ณด๋‹ค ๋น ๋ฅด๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์ง€ ์•Š์„๊นŒ? ๋ผ๋Š” ๊ธฐ๋Œ€๊ฐ์ด ์ƒ๊น๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํ›„์— ์ธ๊ฐ•๊ณผ ์ฑ…์„ ํ†ตํ•ด์„œ ๋ถ€์กฑํ•œ ๋‚ด์šฉ์„ ์Šต๋“ํ•จ๊ณผ ๋™์‹œ์— ๋ณด๋‹ค ๋” ์ดํ•ดํ•˜๊ธฐ์— ์‰ฝ์ง€ ์•Š์„๊นŒ ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

 

 

์ฐธ๊ณ 

์บ์‹œ ์ถ”์ƒํ™” ๋ฌธ์„œ - https://docs.spring.io/spring-framework/reference/integration/cache/strategies.html

์บ์‹œ ์–ด๋…ธํ…Œ์ด์…˜ ๋ฌธ์„œ - https://docs.spring.io/spring-framework/reference/integration/cache/annotations.html#cache-annotations-cacheable