title: Expired Redisson Keys still visible in Redis Cli
body: <p>I just learnt about Redis and Redisson as well. Basically I am trying to use Redis for storing AcessTokens/RefreshTokens used for authorization in my app.
  So I want to store the tokens with an expiration time. I used <strong>Spring Data Redis</strong> to store the token but there is no Api to expire each entry in a Map. I came across this post <a href="https://stackoverflow.com/questions/34893279/spring-data-redis-expire-key">Spring Data Redis Expire Key</a> and hence looked up Redisson. I tried a simple maven java project to test the expiration.
  Here is pom.xml:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.bridgelabz&lt;/groupId&gt;
      &lt;artifactId&gt;redissonApp&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;redissonApp&lt;/name&gt;
      &lt;url&gt;http://maven.apache.org&lt;/url&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;junit&lt;/groupId&gt;
              &lt;artifactId&gt;junit&lt;/artifactId&gt;
              &lt;version&gt;3.8.1&lt;/version&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.redisson&lt;/groupId&gt;
              &lt;artifactId&gt;redisson&lt;/artifactId&gt;
              &lt;version&gt;3.3.0&lt;/version&gt;
          &lt;/dependency&gt;
  
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Below is Token class</p>
  
  <pre><code>package com.bridgelabz.redissonApp;
  
  public class Token {
  
      private String accessToken;
      private int id;
  
      public Token() { }
  
  
      public Token(String accessToken, int id) {
  
          this.accessToken = accessToken;
          this.id = id;
      }
  
      public String getAccessToken() {
          return accessToken;
      }
  
      public void setAccessToken(String accessToken) {
          this.accessToken = accessToken;
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      @Override
      public String toString() {
          return "Token [accessToken=" + accessToken + ", id=" + id + "]";
      }   
  
  }
  </code></pre>
  
  <p>And here is my demo App:</p>
  
  <pre><code>package com.bridgelabz.redissonApp;
  
  import java.util.concurrent.TimeUnit;
  
  import org.redisson.Redisson;
  import org.redisson.api.LocalCachedMapOptions;
  import org.redisson.api.RMapCache;
  import org.redisson.api.RedissonClient;
  import org.redisson.api.LocalCachedMapOptions.EvictionPolicy;
  import org.redisson.config.Config;
  
  
  public class App {
      public static void main(String[] args) {
          Config config = new Config();
  
          config.useSingleServer().setAddress("127.0.0.1:6379");
  
          // LocalCachedMapOptions localCachedMapOptions =
          // LocalCachedMapOptions.defaults()
          // .evictionPolicy(EvictionPolicy.LFU);
  
          RedissonClient redisson = Redisson.create(config);
  
          try {
  
              RMapCache&lt;Integer, Token&gt; map = redisson.getMapCache("TestMap");
  
              Token myToken = new Token("abc", 1);
  
              map.put(1, myToken, 10, TimeUnit.SECONDS);
  
              System.out.println("Stored value with key 1 is: " + map.get(1));
  
          }
  
          finally {
  
              redisson.shutdown();
  
          }
  
      }
  }
  </code></pre>
  
  <p>After running App.java I get the output I get the output as:</p>
  
  <pre><code>SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Stored value with key 1 is: Token [accessToken=abc, id=1]
  </code></pre>
  
  <p>And just commenting the put code and running the app after 10 seconds gives me the partly desired result:</p>
  
  <pre><code>LF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  SLF4J: Defaulting to no-operation (NOP) logger implementation
  SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  Stored value with key 1 is: null
  </code></pre>
  
  <p>But when I run redis-cli I'm still getting the value in the output:</p>
  
  <pre><code>127.0.0.1:6379&gt; hget TestMap 1
  "\x00\x00\x00\x00\x00\x00\x00\x00H\x00\x00\x00\x00\x00\x00\x00{\"@class\":\"com.bridgelabz.redissonApp.Token\",\"accessToken\":\"abc\",\"id\":1}"
  </code></pre>
  
  <p>Why isn't the key removed from redis also? FYI: Everything is being tested on my local machine only including redis.</p>