From f686d97dc80579c953ca105aea393cb00508de19 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 1 Nov 2020 14:32:17 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20SQLite:=20Fix=20no=20expiration?= =?UTF-8?q?=20check=20on=20Set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlite3/sqlite3.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlite3/sqlite3.go b/sqlite3/sqlite3.go index 5ec369fd..123d462d 100644 --- a/sqlite3/sqlite3.go +++ b/sqlite3/sqlite3.go @@ -118,7 +118,11 @@ func (s *Storage) Get(key string) ([]byte, error) { // Set key with value func (s *Storage) Set(key string, val []byte, exp time.Duration) error { - _, err := s.db.Exec(s.sqlInsert, key, utils.UnsafeString(val), time.Now().Add(exp).Unix()) + var expSeconds int64 + if exp != 0 { + expSeconds = time.Now().Add(exp).Unix() + } + _, err := s.db.Exec(s.sqlInsert, key, utils.UnsafeString(val), expSeconds) return err }