title: Spring Data RedisTemplate, ttl is not working when setting a value
body: <p>I want to set a ttl for my keys that are stored in Redis, and I have done that in the following way: </p>
  
  <pre><code>@Component
  public class RedisBetgeniusMarketService implements BetgeniusMarketService {
  
      private static final int DEFAULT_EVENTS_LIFE_TIME = 240;
  
      @Value("${redis.events.lifetime}")
      private long eventsLifeTime = DEFAULT_EVENTS_LIFE_TIME;
  
      @Autowired
      private RedisTemplate&lt;String, Market&gt; marketTemplate;
  
      @Override
      public Market findOne(Integer fixtureId, Long marketId) {
          String key = buildKey(fixtureId, marketId);
          return marketTemplate.boundValueOps(key).get();
      }
  
      @Override
      public void save(Integer fixtureId, Market market) {
          String key = buildKey(fixtureId, market.getId());
          BoundValueOperations&lt;String, Market&gt; boundValueOperations = marketTemplate.boundValueOps(key);
          boundValueOperations.expire(eventsLifeTime, TimeUnit.MINUTES);
          boundValueOperations.set(market);
      }
  
      private String buildKey(Integer fixtureId, Long marketId) {
          return "market:" + fixtureId + ":" + marketId;
      }
  }
  </code></pre>
  
  <p>But, when I am printing the ttl of the created key it's equal to <code>-1</code>. </p>
  
  <p><strong>Please, tell me what I am doing wrong.</strong></p>
  
  <p>The template bean is configured in the following way: </p>
  
  <pre><code>    @Bean
      public RedisTemplate&lt;String, com.egalacoral.spark.betsync.entity.Market&gt; marketTemplate(RedisConnectionFactory connectionFactory) {
          final RedisTemplate&lt;String, com.egalacoral.spark.betsync.entity.Market&gt; redisTemplate = new RedisTemplate&lt;&gt;();
          redisTemplate.setKeySerializer(new StringRedisSerializer());
          redisTemplate.setValueSerializer(new Jackson2JsonRedisSerializer(com.egalacoral.spark.betsync.entity.Market.class));
          redisTemplate.setConnectionFactory(connectionFactory);
          return redisTemplate;
      } 
  </code></pre>