fixed EduSetting删除时清除缓存
This commit is contained in:
		
							parent
							
								
									55f60bf062
								
							
						
					
					
						commit
						8b968d3f1a
					
				| 
						 | 
				
			
			@ -17,6 +17,7 @@
 | 
			
		|||
 | 
			
		||||
class EduSetting < ApplicationRecord
 | 
			
		||||
  after_commit :expire_value_cache
 | 
			
		||||
  after_commit :clear_value_cache, on: :destroy
 | 
			
		||||
 | 
			
		||||
  scope :by_search,     -> (keyword){ where("name LIKE :keyword OR value LIKE :keyword", keyword: "%#{strip_param(keyword)}%") unless strip_param(keyword).blank? }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,4 +46,8 @@ class EduSetting < ApplicationRecord
 | 
			
		|||
  def expire_value_cache
 | 
			
		||||
    Rails.cache.write(value_cache_key, value)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def clear_value_cache
 | 
			
		||||
    Rails.cache.delete(value_cache_key)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue