Class: AdditionalTagsRemoveUnusedTagJob

Inherits:
AdditionalTagsJob show all
Defined in:
app/jobs/additional_tags_remove_unused_tag_job.rb

Instance Method Summary collapse

Instance Method Details

#performObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/jobs/additional_tags_remove_unused_tag_job.rb', line 4

def perform
  if Rails.env.test?
    # no cache for testing
    AdditionalTags::Tags.remove_unused_tags
  else
    # only once a minute to reduce load
    cache = ActiveSupport::Cache::MemoryStore.new expires_in: 1.minute
    cache.fetch self.class.to_s do
      AdditionalTags::Tags.remove_unused_tags
      true
    end
  end
end