Class: StandardId::CleanupExpiredSessionsJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- StandardId::CleanupExpiredSessionsJob
- Defined in:
- app/jobs/standard_id/cleanup_expired_sessions_job.rb
Instance Method Summary collapse
-
#perform(grace_period_seconds: 7.days.to_i) ⇒ Object
Delete sessions that expired more than ‘grace_period_seconds` ago.
Instance Method Details
#perform(grace_period_seconds: 7.days.to_i) ⇒ Object
Delete sessions that expired more than ‘grace_period_seconds` ago. A grace period avoids deleting sessions that just expired and might still be referenced in in-flight requests. Accepts integer seconds for reliable ActiveJob serialization across all queue adapters.
9 10 11 12 13 |
# File 'app/jobs/standard_id/cleanup_expired_sessions_job.rb', line 9 def perform(grace_period_seconds: 7.days.to_i) cutoff = grace_period_seconds.seconds.ago deleted = StandardId::Session.where("expires_at < ?", cutoff).delete_all Rails.logger.info("[StandardId] Cleaned up #{deleted} expired sessions older than #{cutoff}") end |