Class: CacheSweepJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/cache_sweep_job.rb

Instance Method Summary collapse

Instance Method Details

#doorkeeper_cleanup ⇒ Object



11
12
13
14
# File 'app/jobs/cache_sweep_job.rb', line 11

def doorkeeper_cleanup
  Doorkeeper.config.access_token_model.find_each { it.destroy unless it.accessible? }
  Doorkeeper.config.access_grant_model.find_each { it.destroy unless it.accessible? }
end

#perform ⇒ Object



2
3
4
5
6
7
8
9
# File 'app/jobs/cache_sweep_job.rb', line 2

def perform
  cache = ModelFileUploader.storages[:cache]
  cache.clear! { |path| path.mtime < 6.hours.ago }
  # Don't need to clear tus separately, the storage is the same place

  # Clean up expired doorkeeper tokens
  doorkeeper_cleanup
end