|
@@ -43,10 +43,14 @@ func (store *redisStore) GetMultiple(id Id) map[string]interface{} {
|
|
|
lock(id).Unlock()
|
|
|
return m
|
|
|
}
|
|
|
- redis.SetExpire("session", string(id), int(store.maxAge.Seconds()))
|
|
|
+ json.Unmarshal(*bs, &m)
|
|
|
+ timeout := int(store.maxAge.Seconds())
|
|
|
+ if RedisNotLoginKey != "" && m[RedisNotLoginKey] == nil {
|
|
|
+ timeout = RedisNotLoginExpire
|
|
|
+ }
|
|
|
+ redis.SetExpire("session", string(id), timeout)
|
|
|
store.last = time.Now()
|
|
|
lock(id).Unlock()
|
|
|
- json.Unmarshal(*bs, &m)
|
|
|
return m
|
|
|
}
|
|
|
|
|
@@ -69,8 +73,12 @@ func (store *redisStore) SetMultiple(id Id, m map[string]interface{}) {
|
|
|
for k, v := range m {
|
|
|
userdata[k] = v
|
|
|
}
|
|
|
+ timeout := int(store.maxAge.Seconds())
|
|
|
+ if RedisNotLoginKey != "" && m[RedisNotLoginKey] == nil {
|
|
|
+ timeout = RedisNotLoginExpire
|
|
|
+ }
|
|
|
putdata, _ := json.Marshal(userdata)
|
|
|
- redis.PutBytes("session", string(id), &putdata, int(store.maxAge.Seconds()))
|
|
|
+ redis.PutBytes("session", string(id), &putdata, timeout)
|
|
|
}
|
|
|
|
|
|
func (store *redisStore) Add(id Id) {
|
|
@@ -87,8 +95,12 @@ func (store *redisStore) Del(id Id, key string) bool {
|
|
|
var userdata map[string]interface{}
|
|
|
json.Unmarshal(*bs, &userdata)
|
|
|
delete(userdata, key)
|
|
|
+ timeout := int(store.maxAge.Seconds())
|
|
|
+ if RedisNotLoginKey != "" && userdata[RedisNotLoginKey] == nil {
|
|
|
+ timeout = RedisNotLoginExpire
|
|
|
+ }
|
|
|
putdata, _ := json.Marshal(userdata)
|
|
|
- redis.PutBytes("session", string(id), &putdata, int(store.maxAge.Seconds()))
|
|
|
+ redis.PutBytes("session", string(id), &putdata, timeout)
|
|
|
return true
|
|
|
}
|
|
|
|
|
@@ -102,9 +114,13 @@ func (store *redisStore) UpdateByCustomField(findkey string, findvalue interface
|
|
|
}
|
|
|
var data map[string]interface{}
|
|
|
json.Unmarshal(*bs, &data)
|
|
|
+ timeout := int(store.maxAge.Seconds())
|
|
|
+ if RedisNotLoginKey != "" && data[RedisNotLoginKey] == nil {
|
|
|
+ timeout = RedisNotLoginExpire
|
|
|
+ }
|
|
|
data[setkey] = setvalue
|
|
|
putdata, _ := json.Marshal(data)
|
|
|
- redis.PutBytes("session", findkey, &putdata, int(store.maxAge.Seconds()))
|
|
|
+ redis.PutBytes("session", findkey, &putdata, timeout)
|
|
|
return true
|
|
|
}
|
|
|
|