From 0d6bb6302b99418d7edee09e66a025057a3fe938 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Tue, 22 Feb 2022 11:30:44 +0300 Subject: [PATCH] TTL should return the RFC3339 time Signed-off-by: Valery Piashchynski --- kv/kv.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kv/kv.go b/kv/kv.go index 30c54b7..c284586 100644 --- a/kv/kv.go +++ b/kv/kv.go @@ -239,7 +239,13 @@ func (d *Driver) TTL(keys ...string) (map[string]string, error) { return nil, err } - m[key] = duration.String() + // The command returns -2 if the key does not exist. + // The command returns -1 if the key exists but has no associated expire. + if duration == -1 || duration == -2 { + continue + } + + m[key] = time.Now().Add(duration).Format(time.RFC3339) } return m, nil }