mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
fix redis sessions database prefix
This commit is contained in:
parent
0dd03c0e92
commit
2d62d49fdb
|
@ -25,7 +25,7 @@ func main() {
|
||||||
Username: "",
|
Username: "",
|
||||||
Password: "",
|
Password: "",
|
||||||
Database: "",
|
Database: "",
|
||||||
Prefix: "",
|
Prefix: "myapp-",
|
||||||
Driver: redis.GoRedis(), // defautls.
|
Driver: redis.GoRedis(), // defautls.
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ const SessionIDKey = "session_id"
|
||||||
func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime {
|
func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime {
|
||||||
sidKey := db.makeSID(sid)
|
sidKey := db.makeSID(sid)
|
||||||
if !db.c.Driver.Exists(sidKey) {
|
if !db.c.Driver.Exists(sidKey) {
|
||||||
if err := db.Set(sidKey, SessionIDKey, sid, 0, false); err != nil {
|
if err := db.Set(sid, SessionIDKey, sid, 0, false); err != nil {
|
||||||
db.logger.Debug(err)
|
db.logger.Debug(err)
|
||||||
} else if expires > 0 {
|
} else if expires > 0 {
|
||||||
if err := db.c.Driver.UpdateTTL(sidKey, expires); err != nil {
|
if err := db.c.Driver.UpdateTTL(sidKey, expires); err != nil {
|
||||||
|
@ -179,8 +179,8 @@ func (db *Database) Set(sid string, key string, value interface{}, _ time.Durati
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get retrieves a session value based on the key.
|
// Get retrieves a session value based on the key.
|
||||||
func (db *Database) Get(fullSID string, key string) (value interface{}) {
|
func (db *Database) Get(sid string, key string) (value interface{}) {
|
||||||
if err := db.Decode(fullSID, key, &value); err == nil {
|
if err := db.Decode(sid, key, &value); err == nil {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,8 @@ func (db *Database) Get(fullSID string, key string) (value interface{}) {
|
||||||
|
|
||||||
// Decode binds the "outPtr" to the value associated to the provided "key".
|
// Decode binds the "outPtr" to the value associated to the provided "key".
|
||||||
func (db *Database) Decode(sid, key string, outPtr interface{}) error {
|
func (db *Database) Decode(sid, key string, outPtr interface{}) error {
|
||||||
data, err := db.c.Driver.Get(sid, key)
|
sidKey := db.makeSID(sid)
|
||||||
|
data, err := db.c.Driver.Get(sidKey, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// not found.
|
// not found.
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue
Block a user