{
  "id": "cache",
  "title": "Use Redis with the Spring cache abstraction",
  "url": "https://redis.io/docs/latest/integrate/spring-framework-cache/cache/",
  "summary": "Plug Redis into your Spring application as a cache with minimal effort",
  "tags": [
    "docs",
    "integrate",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "client"
  ],
  "last_updated": "2026-07-24T10:52:10-07:00",
  "page_type": "content",
  "content_hash": "0b29104491c68ea5b698f4e6916cfede6869f4be651d3669457e219fee7300db",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Spring Data Redis implements the Spring framework's cache abstraction for Redis, which allows you to plug Redis into your Spring application with minimal effort.\n\nSpring's cache abstraction applies cache-aside to methods, reducing executions by storing and reusing results. When a method is invoked, the abstraction checks if it's been called with the same arguments before. If so, it returns the cached result. If not, it invokes the method, caches the result, and returns it. This way, costly methods are invoked less often. Further details are in the [Spring cache abstraction documentation](https://docs.spring.io/spring-framework/reference/integration/cache.html)."
    },
    {
      "id": "get-started",
      "title": "Get started",
      "role": "content",
      "text": "In a nutshell, you need to perform the following steps to use Redis as your cache storage:\n\n1. [Configure the cache storage](https://docs.spring.io/spring-framework/reference/integration/cache/store-configuration.html) by using the [Redis cache manager](https://docs.spring.io/spring-data/redis/reference/redis/redis-cache.html) that is part of Spring Data.\n2. Annotate a repository with your `@CacheConfig`.\n3. Use the `@Cacheable` annotation on a repository method to cache the results of that method.\n\nHere is an example:\n\n[code example]"
    },
    {
      "id": "further-readings",
      "title": "Further readings",
      "role": "content",
      "text": "Please read the Spring framework's documentation to learn more about how to use the Redis cache abstraction for Spring:\n\n* [Spring cache abstraction](https://docs.spring.io/spring-framework/reference/integration/cache.html)\n* [Spring cache store configuration](https://docs.spring.io/spring-framework/reference/integration/cache/store-configuration.html)\n* [Spring Data Redis Cache](https://docs.spring.io/spring-data/redis/reference/redis/redis-cache.html)"
    }
  ],
  "examples": [
    {
      "id": "get-started-ex0",
      "language": "java",
      "code": "@CacheConfig(\"books\")\npublic class BookRepositoryImpl implements BookRepository {\n\n    @Cacheable\n    public Book findBook(ISBN isbn) {...}\n}",
      "section_id": "get-started"
    }
  ]
}
