Module: Moneta::Adapters::Sequel::Postgres Private
- Defined in:
- lib/moneta/adapters/sequel/postgres.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.
Instance Method Summary collapse
- #delete(key, options = {}) ⇒ Object private
- #each_key ⇒ Object private
- #increment(key, amount = 1, options = {}) ⇒ Object private
- #merge!(pairs, options = {}, &block) ⇒ Object private
- #store(key, value, options = {}) ⇒ Object private
Instance Method Details
#delete(key, 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.
19 20 21 22 23 24 |
# File 'lib/moneta/adapters/sequel/postgres.rb', line 19 def delete(key, = {}) result = @delete.call(key: key) if row = result.first row[config.value_column] end end |
#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.
38 39 40 41 42 43 44 45 |
# File 'lib/moneta/adapters/sequel/postgres.rb', line 38 def each_key return super unless block_given? && !config.each_key_server && @table.respond_to?(:use_cursor) # With a cursor, this will Just Work. @table.select(config.key_column).paged_each do |row| yield row[config.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.
12 13 14 15 16 17 |
# File 'lib/moneta/adapters/sequel/postgres.rb', line 12 def increment(key, amount = 1, = {}) result = @increment.call(key: key, value: blob(amount.to_s), amount: amount) if row = result.first row[config.value_column].to_i 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.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/moneta/adapters/sequel/postgres.rb', line 26 def merge!(pairs, = {}, &block) @backend.transaction do pairs = yield_merge_pairs(pairs, &block) if block_given? @table .insert_conflict(target: config.key_column, update: { config.value_column => ::Sequel[:excluded][config.value_column] }) .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.
7 8 9 10 |
# File 'lib/moneta/adapters/sequel/postgres.rb', line 7 def store(key, value, = {}) @store.call(key: key, value: blob(value)) value end |