Module: Moneta::Adapters::Sequel::SQLite Private
- Defined in:
- lib/moneta/adapters/sequel/sqlite.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .extended(mod) ⇒ Object private
Instance Method Summary collapse
- #increment(key, amount = 1, options = {}) ⇒ Object private
- #merge!(pairs, options = {}, &block) ⇒ Object private
- #store(key, value, options = {}) ⇒ Object private
Class Method Details
.extended(mod) ⇒ 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.
6 7 8 9 10 |
# File 'lib/moneta/adapters/sequel/sqlite.rb', line 6 def self.extended(mod) version = mod.backend.get(::Sequel[:sqlite_version].function) # See https://sqlite.org/lang_UPSERT.html mod.instance_variable_set(:@can_upsert, ::Gem::Version.new(version) >= ::Gem::Version.new('3.24.0')) end |
Instance Method Details
#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.
17 18 19 20 21 22 23 |
# File 'lib/moneta/adapters/sequel/sqlite.rb', line 17 def increment(key, amount = 1, = {}) return super unless @can_upsert @backend.transaction do @increment.call(key: key, value: blob(amount.to_s), amount: amount) Integer(load(key)) end 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.
25 26 27 28 29 30 31 32 |
# File 'lib/moneta/adapters/sequel/sqlite.rb', line 25 def merge!(pairs, = {}, &block) @backend.transaction do pairs = yield_merge_pairs(pairs, &block) if block_given? @table.insert_conflict(:replace).import([config.key_column, config.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.
12 13 14 15 |
# File 'lib/moneta/adapters/sequel/sqlite.rb', line 12 def store(key, value, = {}) @table.insert_conflict(:replace).insert(config.key_column => key, config.value_column => blob(value)) value end |