A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
602 B

  1. class AdminSetting < ActiveRecord::Base
  2. def self.add(key, value)
  3. self.create(key: key, value: value)
  4. end
  5. def self.get(key)
  6. existing = Rails.cache.read("admin_setting/#{key}")
  7. return existing unless existing.nil?
  8. setting = self.find_by(key: key)
  9. return nil if setting.nil?
  10. Rails.cache.write("admin_setting/#{key}", setting.value)
  11. setting.value
  12. end
  13. def self.set(key, value)
  14. existing = self.get(key)
  15. return if existing.nil? || existing == value
  16. self.find_by(key: key).update(value: value)
  17. Rails.cache.write("admin_setting/#{key}", value)
  18. end
  19. end