Class: Moneta::Adapters::Sequel::MySQL Private
- Inherits:
-
Moneta::Adapters::Sequel
- Object
- Moneta::Adapters::Sequel
- Moneta::Adapters::Sequel::MySQL
- Defined in:
- lib/moneta/adapters/sequel.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary
Attributes inherited from Moneta::Adapters::Sequel
#backend, #key_column, #value_column
Instance Method Summary collapse
- #each_key ⇒ Object private
- #increment(key, amount = 1, options = {}) ⇒ Object private
- #merge!(pairs, options = {}, &block) ⇒ Object private
- #store(key, value, options = {}) ⇒ Object private
Methods inherited from Moneta::Adapters::Sequel
#clear, #close, #create, #delete, #fetch_values, #initialize, #key?, #load, new, #slice, #values_at
Methods included from Defaults
#[], #[]=, #close, #create, #decrement, #features, #fetch, #fetch_values, included, #key?, #slice, #supports?, #update, #values_at
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
This class inherits a constructor from Moneta::Adapters::Sequel
Instance Method Details
#each_key ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
364 365 366 367 368 369 370 371 |
# File 'lib/moneta/adapters/sequel.rb', line 364 def each_key return super unless block_given? && @each_key_server && @table.respond_to?(:stream) # Order is not required when streaming @table.server(@each_key_server).select(key_column).paged_each do |row| yield row[key_column] end self end |
#increment(key, amount = 1, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/moneta/adapters/sequel.rb', line 335 def increment(key, amount = 1, = {}) @backend.transaction do # this creates a row-level lock even if there is no existing row (a # "gap lock"). if row = @load_for_update.call(key: key) # Integer() will raise an exception if the existing value cannot be parsed amount += Integer(row[value_column]) @increment_update.call(key: key, value: amount) else @create.call(key: key, value: amount) end amount end rescue ::Sequel::SerializationFailure # Thrown on deadlock tries ||= 0 (tries += 1) <= 3 ? retry : raise end |
#merge!(pairs, options = {}, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
353 354 355 356 357 358 359 360 361 362 |
# File 'lib/moneta/adapters/sequel.rb', line 353 def merge!(pairs, = {}, &block) @backend.transaction do pairs = yield_merge_pairs(pairs, &block) if block_given? @table .on_duplicate_key_update .import([key_column, value_column], blob_pairs(pairs).to_a) end self end |
#store(key, value, options = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
330 331 332 333 |
# File 'lib/moneta/adapters/sequel.rb', line 330 def store(key, value, = {}) @store.call(key: key, value: blob(value)) value end |