title: How to get expiration time for a key on Redis using Dotnet Core?
body: <p>I'm following <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.caching.distributed.distributedcacheextensions.getstring" rel="nofollow noreferrer">this example</a> to implement Redis cache on Dotnet Core.</p>
  
  <p>Unfortunately t seems that both Get(key) and GetString(key) only return the value, not the metadata such as expiry.</p>
  
  <p>When I use redis-cli I'm able to retrieve both the data and metadata using <code>HGETALL key</code></p>
  
  <pre><code>1) "absexp"
  2) "637153531959962660"
  3) "data"
  4) "[{&lt;snip&gt;}]"
  5) "sldexp"
  6) "-1"
  </code></pre>
  
  <p>Is there any way to access this metadata from my code?</p>
  
  <p>There might of course be workarounds like adding the expiry in the data object itself or adding a second key that contains the metadata, but neither solutions are very elegant.</p>