feat(session): support v1
support v1
This commit is contained in:
@@ -75,6 +75,13 @@ func (ls *SessionStore) SessionRelease(w http.ResponseWriter) {
|
||||
c.Expire([]byte(ls.sid), ls.maxlifetime)
|
||||
}
|
||||
|
||||
// SessionReleaseIfPresent is not supported now, because ledis has no this feature like SETXX or atomic operation.
|
||||
// https://github.com/ledisdb/ledisdb/issues/251
|
||||
// https://github.com/ledisdb/ledisdb/issues/351
|
||||
func (ls *SessionStore) SessionReleaseIfPresent(w http.ResponseWriter) {
|
||||
ls.SessionRelease(w)
|
||||
}
|
||||
|
||||
// Provider ledis session provider
|
||||
type Provider struct {
|
||||
maxlifetime int64
|
||||
@@ -141,8 +148,8 @@ func (lp *Provider) SessionExist(sid string) bool {
|
||||
func (lp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error) {
|
||||
count, _ := c.Exists([]byte(sid))
|
||||
if count == 0 {
|
||||
// oldsid doesn't exists, set the new sid directly
|
||||
// ignore error here, since if it return error
|
||||
// oldsid doesn't exist, set the new sid directly
|
||||
// ignore error here, since if it returns error
|
||||
// the existed value will be 0
|
||||
c.Set([]byte(sid), []byte(""))
|
||||
c.Expire([]byte(sid), lp.maxlifetime)
|
||||
@@ -160,7 +167,7 @@ func (lp *Provider) SessionDestroy(sid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SessionGC Impelment method, no used.
|
||||
// SessionGC Implement method, no used.
|
||||
func (lp *Provider) SessionGC() {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user