Module: Moneta::Adapters::Sequel::Postgres Private

Defined in:
lib/moneta/adapters/sequel/postgres.rb

Overview

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.

API:

  • private

Instance Method Summary collapse

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.

API:

  • private



19
20
21
22
23
24
# File 'lib/moneta/adapters/sequel/postgres.rb', line 19

def delete(key, options = {})
  result = @delete.call(key: key)
  if row = result.first
    row[config.value_column]
  end
end

#each_keyObject

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.

API:

  • private



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.

API:

  • private



12
13
14
15
16
17
# File 'lib/moneta/adapters/sequel/postgres.rb', line 12

def increment(key, amount = 1, options = {})
  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.

API:

  • private



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/moneta/adapters/sequel/postgres.rb', line 26

def merge!(pairs, options = {}, &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.

API:

  • private



7
8
9
10
# File 'lib/moneta/adapters/sequel/postgres.rb', line 7

def store(key, value, options = {})
  @store.call(key: key, value: blob(value))
  value
end