cache.TTL provides a GetOrSet() method

 * attempts to get the value associated with the given key, and when
   the result would be not found, it sets the value to the result of
   invoking the provided call back function.