Module: Ultrafast::Model
- Defined in:
- lib/ultrafast/model.rb
Instance Method Summary collapse
- #current_application_name ⇒ Object
- #error_message ⇒ Object
- #fast_create(*attributes) ⇒ Object
- #fast_default_amount ⇒ Object
- #has_fast_create ⇒ Object
- #redis_connection ⇒ Object
Instance Method Details
#current_application_name ⇒ Object
27 28 29 |
# File 'lib/ultrafast/model.rb', line 27 def current_application_name Ultrafast::CurrentApplication.name end |
#error_message ⇒ Object
31 32 33 34 35 |
# File 'lib/ultrafast/model.rb', line 31 def Rails.logger.warn '-----------------------------------------------------' Rails.logger.warn '[WARN Error] on try use fastcreate, running fallback' Rails.logger.warn '-----------------------------------------------------' end |
#fast_create(*attributes) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 |
# 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) self.new(attributes) rescue self.create(*attributes) end |
#fast_default_amount ⇒ Object
19 20 21 |
# File 'lib/ultrafast/model.rb', line 19 def fast_default_amount 100 end |
#has_fast_create ⇒ Object
15 16 17 |
# File 'lib/ultrafast/model.rb', line 15 def has_fast_create true end |
#redis_connection ⇒ Object
23 24 25 |
# File 'lib/ultrafast/model.rb', line 23 def redis_connection Ultrafast::Storage.redis_connection end |