# NTTL

> Return a key's remaining time to live in nanoseconds.

URL: https://docs.hotkv.com/commands/nttl/

```
NTTL key
```

- Group: Keys
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`NTTL` returns how many nanoseconds are left before `key` expires. It works
for any time to live, however it was set ([EXPIRE](https://docs.hotkv.com/commands/expire/index.md),
[SET](https://docs.hotkv.com/commands/set/index.md) with `PX`, [NEXPIRE](https://docs.hotkv.com/commands/nexpire/index.md), and so on).

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| The key has a time to live | Integer: nanoseconds left | Integer |
| The key exists without a time to live | Integer `-1` | Integer `-1` |
| The key does not exist | Integer `-2` | Integer `-2` |

## Examples

```
127.0.0.1:6379> SET lease "worker-3"
OK
127.0.0.1:6379> NEXPIRE lease 5000000
(integer) 1
127.0.0.1:6379> NTTL lease
(integer) 4981233
127.0.0.1:6379> NTTL missing
(integer) -2
```

## Compatibility

HotKV-only command.

## See also

[NEXPIRE](https://docs.hotkv.com/commands/nexpire/index.md), [NEXPIREAT](https://docs.hotkv.com/commands/nexpireat/index.md),
[PTTL](https://docs.hotkv.com/commands/pttl/index.md), [TTL](https://docs.hotkv.com/commands/ttl/index.md)