Module: Cacheable

Extended by:
ActiveSupport::Concern
Included in:
Api::V1::JobsController, Api::V1::UsersController
Defined in:
app/controllers/concerns/cacheable.rb

Overview

app/controllers/concerns/cacheable.rb

Instance Method Summary collapse

Instance Method Details

#invalidate_cache(namespace, id: nil, skip_show: false) ⇒ Object

Menghapus cache terkait job tertentu (dan index)



6
7
8
9
10
11
12
13
14
# File 'app/controllers/concerns/cacheable.rb', line 6

def invalidate_cache(namespace, id: nil, skip_show: false)
  Rails.logger.info("[CACHE] Deleting #{namespace}/index/*")
  Rails.cache.delete_matched("#{namespace}/index/*")

  unless skip_show || id.nil?
    Rails.logger.info("[CACHE] Deleting #{namespace}/show/#{id}/*")
    Rails.cache.delete_matched("#{namespace}/show/#{id}/*")
  end
end