mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
@@ -53,7 +53,7 @@ func (s *Session) ID() string {
|
||||
return s.sid
|
||||
}
|
||||
|
||||
// IsNew returns true if this session is
|
||||
// IsNew returns true if this session is just
|
||||
// created by the current application's process.
|
||||
func (s *Session) IsNew() bool {
|
||||
return s.isNew
|
||||
@@ -64,6 +64,11 @@ func (s *Session) Get(key string) interface{} {
|
||||
return s.provider.db.Get(s.sid, key)
|
||||
}
|
||||
|
||||
// Decode binds the given "outPtr" to the value associated to the provided "key".
|
||||
func (s *Session) Decode(key string, outPtr interface{}) error {
|
||||
return s.provider.db.Decode(s.sid, key, outPtr)
|
||||
}
|
||||
|
||||
// when running on the session manager removes any 'old' flash messages.
|
||||
func (s *Session) runFlashGC() {
|
||||
s.mu.Lock()
|
||||
@@ -517,11 +522,7 @@ func (s *Session) Len() int {
|
||||
}
|
||||
|
||||
func (s *Session) set(key string, value interface{}, immutable bool) {
|
||||
s.provider.db.Set(s.sid, s.Lifetime, key, value, immutable)
|
||||
|
||||
s.mu.Lock()
|
||||
s.isNew = false
|
||||
s.mu.Unlock()
|
||||
s.provider.db.Set(s.sid, key, value, s.Lifetime.DurationUntilExpiration(), immutable)
|
||||
}
|
||||
|
||||
// Set fills the session with an entry "value", based on its "key".
|
||||
@@ -569,12 +570,6 @@ func (s *Session) SetFlash(key string, value interface{}) {
|
||||
// returns true if actually something was removed.
|
||||
func (s *Session) Delete(key string) bool {
|
||||
removed := s.provider.db.Delete(s.sid, key)
|
||||
if removed {
|
||||
s.mu.Lock()
|
||||
s.isNew = false
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
return removed
|
||||
}
|
||||
|
||||
@@ -587,10 +582,7 @@ func (s *Session) DeleteFlash(key string) {
|
||||
|
||||
// Clear removes all entries.
|
||||
func (s *Session) Clear() {
|
||||
s.mu.Lock()
|
||||
s.provider.db.Clear(s.sid)
|
||||
s.isNew = false
|
||||
s.mu.Unlock()
|
||||
}
|
||||
|
||||
// ClearFlashes removes all flash messages.
|
||||
|
||||
Reference in New Issue
Block a user