Sha256: ae67c9e6f1b1a829690bd6a8ef38320ae41af7e74d69e4850b79bc53afb86374

Contents?: true

Size: 409 Bytes

Versions: 4

Compression:

Stored size: 409 Bytes

Contents

module RailsSettings
	class CachedSettings < Settings
    after_update :rewrite_cache    
    after_create :rewrite_cache
		def rewrite_cache
			Rails.cache.write("settings:#{self.var}", self.value)
		end
    
   before_destroy { |record| Rails.cache.delete("settings:#{record.var}") }
    

		def self.[](var_name)
			Rails.cache.fetch("settings:#{var_name}") {
				super(var_name)
			}
    end    
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-settings-cached-0.2.2 lib/rails-settings/cached_settings.rb
rails-settings-cached-0.2.1 lib/rails-settings/cached_settings.rb
rails-settings-cached-0.2.0 lib/rails-settings/cached_settings.rb
rails-settings-cached-0.1.2 lib/rails-settings/cached_settings.rb