code: def ttl(self, key, **opts):
          
          key, store = self._expand_opts(key, opts)
          if hasattr(store, 'ttl'):
              return store.ttl(key)
          data = store.get(key)
          if data is None:
              return None
          expiry = data[EXPIRY_INDEX]
          if expiry is not None:
              return max(0, expiry - time()) or None
docs: Get the time-to-live of a given key; None if not set.