title: How do I get all the keys from a redis cache via Spring Boot?
body: <p>I have a service method that caches with redis cache via Spring Boot (using <code>compile("org.springframework.boot:spring-boot-starter-data-redis:1.5.6.RELEASE")</code>):</p>
  
  <pre><code>@Cacheable( value = "test" )
  public CacheTestObject getTestObject(String name)
  {
      return new CacheTestObject( name );
  }
  </code></pre>
  
  <p>This works but when i try to get all the keys (and see it there) I get:</p>
  
  <pre><code>//This returns 0 keys
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).keys( "*" )
  </code></pre>
  
  <p>But this returns true:</p>
  
  <pre><code>( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "Joe" )
  </code></pre>
  
  <p>And the following are all:</p>
  
  <pre><code>//TRUE
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "Joe" )
  
  //TRUE
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "J*e" )
  
  //FALSE
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "Jo*" )
  
  //FALSE
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "*oe" )
  
  //FALSE
  ( ( RedisTemplate ) cacheManager.getCache("test").getNativeCache() ).hasKey( "*" )
  </code></pre>
  
  <p>Why is this? Why can't I get all keys with the pattern "<em>"? Or even "J</em>"?</p>
  
  <p>If I do any pattern query where "*" is first or last, it returns no keys.</p>