Class: Moneta::Adapters::Sequel::SQLite Private
- Inherits:
-
Moneta::Adapters::Sequel
- Object
- Moneta::Adapters::Sequel
- Moneta::Adapters::Sequel::SQLite
- 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
- #increment(key, amount = 1, options = {}) ⇒ Object private
-
#initialize(options) ⇒ SQLite
constructor
private
A new instance of SQLite.
- #merge!(pairs, options = {}, &block) ⇒ Object private
- #store(key, value, options = {}) ⇒ Object private
Methods inherited from Moneta::Adapters::Sequel
#clear, #close, #create, #delete, #each_key, #fetch_values, #key?, #load, new, #slice, #values_at
Methods included from Defaults
#[], #[]=, #close, #create, #decrement, #each_key, #features, #fetch, #fetch_values, included, #key?, #slice, #supports?, #update, #values_at
Methods included from OptionSupport
#expires, #prefix, #raw, #with
Constructor Details
#initialize(options) ⇒ SQLite
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.
Returns a new instance of SQLite.
701 702 703 704 705 706 |
# File 'lib/moneta/adapters/sequel.rb', line 701 def initialize() @version = backend.get(::Sequel[:sqlite_version].function) # See https://sqlite.org/lang_UPSERT.html @can_upsert = ::Gem::Version.new(@version) >= ::Gem::Version.new('3.24.0') super 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.
713 714 715 716 717 718 719 |
# File 'lib/moneta/adapters/sequel.rb', line 713 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.
721 722 723 724 725 726 727 728 |
# File 'lib/moneta/adapters/sequel.rb', line 721 def merge!(pairs, = {}, &block) @backend.transaction do pairs = yield_merge_pairs(pairs, &block) if block_given? @table.insert_conflict(:replace).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.
708 709 710 711 |
# File 'lib/moneta/adapters/sequel.rb', line 708 def store(key, value, = {}) @table.insert_conflict(:replace).insert(key_column => key, value_column => blob(value)) value end |