Module: Ultrafast::Model
- Defined in:
- lib/ultrafast/model.rb
Instance Method Summary collapse
- #current_application_name ⇒ Object
- #error_message(exception) ⇒ Object
- #fast_create(*attributes) ⇒ Object
- #fast_default_amount ⇒ Object
- #has_fast_create ⇒ Object
- #redis_connection ⇒ Object
Instance Method Details
#current_application_name ⇒ Object
26 27 28 |
# File 'lib/ultrafast/model.rb', line 26 def current_application_name Ultrafast::CurrentApplication.name end |
#error_message(exception) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/ultrafast/model.rb', line 30 def (exception) Rails.logger.error exception.backtrace Rails.logger.error '-----------------------------------------------------' Rails.logger.error '[WARN Error] on try use fastcreate, running fallback' Rails.logger.error '-----------------------------------------------------' end |
#fast_create(*attributes) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ultrafast/model.rb', line 3 def fast_create(*attributes) uuid = SecureRandom.uuid store_key = "#{self.current_application_name}.#{self.name}.create.#{Time.now.to_i}.#{uuid}" content = attributes.to_json redis_connection.set(store_key, content) rescue => exception (exception) self.create(*attributes) end |
#fast_default_amount ⇒ Object
18 19 20 |
# File 'lib/ultrafast/model.rb', line 18 def fast_default_amount 100 end |
#has_fast_create ⇒ Object
14 15 16 |
# File 'lib/ultrafast/model.rb', line 14 def has_fast_create true end |
#redis_connection ⇒ Object
22 23 24 |
# File 'lib/ultrafast/model.rb', line 22 def redis_connection Ultrafast::Storage.redis_connection end |