title: How to use Redis as a session for authentication in spring Boot application
body: <p>How can I use Redis for handling a session for authentication in a Spring Boot application?</p>
  
  <p>I tried with using <code>expire()</code> of the <code>RedisTemplate</code> class:</p>
  
  <pre><code>String redisKeyExpiryTime=environment.getProperty("app.redisKeyExpiryTime");
  long redisKeyExpiry=Long.parseLong(redisKeyExpiryTime);
  redisTemplate.expire(tokenId,1,TimeUnit.MINUTES);
  hashOperations.put(userId,tokenId,token);
  </code></pre>
  
  <p>But it is not expiring that key. I am getting value against that tokenId Key even after expiration time over.</p>