mirror of
https://gitee.com/johng/gf.git
synced 2024-12-03 12:47:50 +08:00
Merge pull request #738 from fxk2006/fix_SessionRedis
This commit is contained in:
commit
55f9b121de
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user