title: Multiple conditional cache on spring boot application
body: <p>I would like to cache the response based on parameter with multiple conditions. I'm giving below example</p>
  <pre><code>@Caching(
              cacheable = {
                  @Cacheable(cacheNames =&quot;student_name_&quot;, key= &quot;#id&quot;, condition = &quot;#id == 1&quot;),
                  @Cacheable(cacheNames =&quot;student_name_&quot;, key= &quot;#id&quot;, condition = &quot;#id == 2&quot;)                 
              }
        )
        public Student getStudentByID(String id) 
        {
          try
          {
            System.out.println(&quot;Going to sleep for 5 Secs.. to simulate backend call.&quot;);
            Thread.sleep(1000*5);
          } 
          catch (InterruptedException e) 
          {
            e.printStackTrace();
          }
          if(id.equalsIgnoreCase(&quot;1&quot;)) return new Student(id,&quot;Venkat&quot;,&quot;V&quot;);
          else if(id.equalsIgnoreCase(&quot;2&quot;)) return new Student(id,&quot;Jeshwin&quot;,&quot;J&quot;);
          else
          return new Student(id,&quot;Sajal&quot; ,&quot;V&quot;+ new java.util.Date());
        }
  </code></pre>
  <p>In above example, Student with id 1 and 2 are cached and rest should be going to fetch results with normal flow.</p>
  <p>Please let me know, your thoughts.</p>
  <p>Tried caching the response with these annotations...but it is not working as expected...</p>
  <pre><code>@Caching(
              cacheable = {
                  @Cacheable(cacheNames =&quot;student_name_&quot;, key= &quot;#id&quot;, condition = &quot;#id == 1&quot;),
                  @Cacheable(cacheNames =&quot;student_name_&quot;, key= &quot;#id&quot;, condition = &quot;#id == 2&quot;)                 
              }
        )
  </code></pre>