title: Set TTL in Redis to keys with namespace
body: <p>We have a requirement to set a time to live for all the redis cache keys that starts with a paticular namespace in our java spring application</p>
  
  <p>Key format is "abc:xyz:12345.." and we would like to set a default TTL  on all the keys that start with  the namespace "abc". The namespace is programatically built.</p>
  
  <p>Now from what I have read, the notion of setting a default TTL does not exist in Redis and we must set it for every key seperately.</p>
  
  <p>But is there a place ( for example in the RedisTemplate or RedisCaheManger etc) where we could configure it so that every key is created with a default ttl instead of -1</p>
  
  <p>We tried some approaches with Redis Cache Manager and Keyspace settings (  keyspaceSettings.setTimeToLive(long)) but were unsuccessful</p>
  
  <p>Is it possible anyway using Redis Cache manager (like it is mentioned in this stackoverflow link : <a href="https://stackoverflow.com/questions/34893279/spring-data-redis-expire-key">Spring Data Redis Expire Key</a>) to set a ttl for a set of keys with the setDefaultExpiration or setExpires method. 
  Can it be used to set the TTL of all the keys generated or are they referring to setting the "cache" expiry and not the "key" expiry here.</p>
  
  <p>Would greatly appreciate if any has tried to implement a default TTL or if you have an approach we could try out.</p>