Class: SWS::SessionCleaner
- Inherits:
-
Thread
- Object
- Thread
- SWS::SessionCleaner
- Defined in:
- lib/sws/session.rb
Instance Method Summary collapse
-
#initialize(sessions, mutex, session_timeout = 21600, cleanup_interval = 600) ⇒ SessionCleaner
constructor
By default cleaning will be performed every 10 minutes and each session inactive for 6 hours will be deleted.
Constructor Details
#initialize(sessions, mutex, session_timeout = 21600, cleanup_interval = 600) ⇒ SessionCleaner
By default cleaning will be performed every 10 minutes and each session inactive for 6 hours will be deleted
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/sws/session.rb', line 93 def initialize ( sessions, mutex, session_timeout = 21600, cleanup_interval = 600 ) super do |sessions, mutex, session_timeout, cleanup_interval| loop do mutex.synchronize { sessions.delete_if() { |key, value| ( Time.now - value.last_access_time ) > session_timeout } } sleep cleanup_interval end end end |