# Springでのキャッシング (Spring Boot) > Springでのキャッシング: @Cacheable、@CacheEvict、@CachePut、CacheManager、プロバイダー (EhCache、Redis、Caffeine) - 25 面接問題 - Mid-Level - [面接問題: Spring Boot](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions.md) ## 1. Springにおける@Cacheableアノテーションの主な役割は何ですか? **回答** @Cacheableはメソッドの結果をキャッシュし、同じパラメータでの繰り返し実行を回避します。これにより、データベースクエリや外部API呼び出しのようなコストの高い操作のパフォーマンスが大幅に向上します。同じ引数で頻繁に呼び出される読み取りメソッドに@Cacheableを使用して、リソースへの負荷を軽減しましょう。 ## 2. Spring Bootアプリケーションでキャッシングのサポートを有効にするために必要なアノテーションはどれですか? **回答** @EnableCachingはSpring Bootでキャッシングのサポートを有効にし、設定クラス(通常は@SpringBootApplicationでアノテーションされたメインクラス)に配置する必要があります。このアノテーションがないと、@Cacheableなどのキャッシュアノテーションは無視されます。他に定義がなければ、Spring Bootは自動的にシンプルなインメモリCacheManager(ConcurrentMapCacheManager)を構成します。 ## 3. @Cacheableと@CachePutの主な違いは何ですか? **回答** @Cacheableは結果がすでにキャッシュされている場合はメソッドの実行をスキップしますが、@CachePutは常にメソッドを実行し、新しい結果でキャッシュを更新します。読み取り(繰り返しの計算を回避)には@Cacheableを、メソッドの実行を回避せずにキャッシュを更新する必要がある更新操作には@CachePutを使用しましょう。 ## さらに22問利用可能 - Springにおける@CacheEvictアノテーションの役割は何ですか? - 他に定義がない場合、Spring Bootがデフォルトで構成するCacheManagerはどれですか? 無料で登録: https://sharpskill.dev/ja/login ## その他のSpring Boot面接トピック - [Spring Core - IoC & DI](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-core-ioc-di.md): 22問, Junior - [Spring Boot Auto-Configuration](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-auto-configuration.md): 20問, Junior - [Spring Boot Starters](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-starters.md): 18問, Junior - [Application Properties & YAML](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/application-properties-yml.md): 16問, Junior - [SLF4J と Logback によるロギング](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/logging.md): 20問, Junior - [Spring Boot DevTools](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-devtools.md): 15問, Junior - [Spring MVC Basics](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-mvc-basics.md): 20問, Mid-Level - [Spring REST Controllers](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-rest-controllers.md): 20問, Mid-Level - [Request & Response Handling](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/request-response-handling.md): 20問, Mid-Level - [例外処理](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/exception-handling.md): 25問, Mid-Level - [Bean Validation](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/bean-validation.md): 25問, Mid-Level - [Spring Data JPA の基礎](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-data-jpa-basics.md): 25問, Mid-Level - [JPA エンティティとリレーションシップ](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/jpa-entities-relationships.md): 30問, Mid-Level - [JPA クエリ](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/jpa-queries.md): 30問, Mid-Level - [Spring Data Repositories](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-data-repositories.md): 25問, Mid-Level - [Spring Security の基礎](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-security-basics.md): 25問, Mid-Level - [Spring Boot Actuator](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-actuator.md): 20問, Mid-Level - [JUnit と Mockito による単体テスト](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/testing-junit-mockito.md): 30問, Mid-Level - [Spring Boot のテスト](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-testing.md): 30問, Mid-Level - [Profiles と Environment](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/profiles-environment.md): 20問, Mid-Level - [RestTemplate と WebClient](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/resttemplate-webclient.md): 24問, Mid-Level - [Async とスケジューリング](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/async-scheduling.md): 25問, Mid-Level - [Spring WebFlux (リアクティブ)](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-webflux.md): 25問, Mid-Level - [Spring トランザクション](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/transactions.md): 30問, Senior - [高度な認証と認可](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/authentication-authorization.md): 30問, Senior - [JWT とステートレスセキュリティ](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/jwt-stateless-security.md): 20問, Senior - [OAuth2 と Authorization Server](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/oauth2-authorization-server.md): 20問, Senior - [Spring Boot と Docker](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-boot-docker.md): 19問, Senior - [Spring によるマイクロサービス](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/microservices-basics.md): 25問, Senior - [Spring Cloud Config](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/spring-cloud-config.md): 19問, Senior - [パフォーマンス最適化](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/performance-optimization.md): 30問, Senior - [GraalVM Native Images](https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/graalvm-native-images.md): 20問, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/ja/technologies/spring-boot/interview-questions/caching