From f6d760e90f3d6be01f4656c91e59e997ef637649 Mon Sep 17 00:00:00 2001 From: fangxiaokai Date: Tue, 16 Jun 2020 11:19:08 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BF=AE=E5=A4=8Dredis=E5=AD=98?= =?UTF-8?q?=E5=82=A8session=E6=97=B6=EF=BC=8C=E6=9C=80=E5=A4=A7=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E9=97=AE=E9=A2=98:=20ttl.Seconds()?= =?UTF-8?q?=E8=BF=94=E5=9B=9Efloat64=E5=9C=A8redis=E4=B8=AD=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- os/gsession/gsession_storage_redis.go | 5 +++-- os/gsession/gsession_storage_redis_hashtable.go | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/os/gsession/gsession_storage_redis.go b/os/gsession/gsession_storage_redis.go index 5cb36976d..c1b13d6de 100644 --- a/os/gsession/gsession_storage_redis.go +++ b/os/gsession/gsession_storage_redis.go @@ -8,10 +8,11 @@ package gsession import ( "encoding/json" + "time" + "github.com/gogf/gf/container/gmap" "github.com/gogf/gf/database/gredis" "github.com/gogf/gf/internal/intlog" - "time" "github.com/gogf/gf/os/gtimer" ) @@ -147,7 +148,7 @@ func (s *StorageRedis) SetSession(id string, data *gmap.StrAnyMap, ttl time.Dura if err != nil { return err } - _, err = s.redis.DoVar("SETEX", s.key(id), ttl.Seconds(), content) + _, err = s.redis.DoVar("SETEX", s.key(id), int64(ttl.Seconds()), content) return err } diff --git a/os/gsession/gsession_storage_redis_hashtable.go b/os/gsession/gsession_storage_redis_hashtable.go index cd8fec536..b7eec2970 100644 --- a/os/gsession/gsession_storage_redis_hashtable.go +++ b/os/gsession/gsession_storage_redis_hashtable.go @@ -7,11 +7,12 @@ package gsession import ( + "time" + "github.com/gogf/gf/container/gmap" "github.com/gogf/gf/database/gredis" "github.com/gogf/gf/internal/intlog" "github.com/gogf/gf/util/gconv" - "time" ) // StorageRedisHashTable implements the Session Storage interface with redis hash table. @@ -134,7 +135,7 @@ func (s *StorageRedisHashTable) GetSession(id string, ttl time.Duration, data *g // This copy all session data map from memory to storage. func (s *StorageRedisHashTable) SetSession(id string, data *gmap.StrAnyMap, ttl time.Duration) error { intlog.Printf("StorageRedisHashTable.SetSession: %s, %v", id, ttl) - _, err := s.redis.Do("EXPIRE", s.key(id), ttl.Seconds()) + _, err := s.redis.Do("EXPIRE", s.key(id), int64(ttl.Seconds())) return err } @@ -143,7 +144,7 @@ func (s *StorageRedisHashTable) SetSession(id string, data *gmap.StrAnyMap, ttl // It just adds the session id to the async handling queue. func (s *StorageRedisHashTable) UpdateTTL(id string, ttl time.Duration) error { intlog.Printf("StorageRedisHashTable.UpdateTTL: %s, %v", id, ttl) - _, err := s.redis.Do("EXPIRE", s.key(id), ttl.Seconds()) + _, err := s.redis.Do("EXPIRE", s.key(id), int64(ttl.Seconds())) return err }