Class: Moneta::Adapters::Sequel::Postgres Private

Inherits:
Moneta::Adapters::Sequel show all
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.

Constant Summary

Constants inherited from Moneta::Adapters::Sequel

UniqueConstraintViolation

Instance Attribute Summary

Attributes inherited from Moneta::Adapters::Sequel

#backend, #key_column, #value_column

Instance Method Summary collapse

Methods inherited from Moneta::Adapters::Sequel

#clear, #close, #create, #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

#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.



407
408
409
410
411
412
# File 'lib/moneta/adapters/sequel.rb', line 407

def delete(key, options = {})
  result = @delete.call(key: key)
  if row = result.first
    row[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.



427
428
429
430
431
432
433
434
# File 'lib/moneta/adapters/sequel.rb', line 427

def each_key
  return super unless block_given? && !@each_key_server && @table.respond_to?(:use_cursor)
  # With a cursor, this will Just Work.
  @table.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.



400
401
402
403
404
405
# File 'lib/moneta/adapters/sequel.rb', line 400

def increment(key, amount = 1, options = {})
  result = @increment.call(key: key, value: blob(amount.to_s), amount: amount)
  if row = result.first
    row[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.



414
415
416
417
418
419
420
421
422
423
424
425
# File 'lib/moneta/adapters/sequel.rb', line 414

def merge!(pairs, options = {}, &block)
  @backend.transaction do
    pairs = yield_merge_pairs(pairs, &block) if block_given?
    @table.
      insert_conflict(
        target: key_column,
        update: {value_column => ::Sequel[:excluded][value_column]}).
      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.



395
396
397
398
# File 'lib/moneta/adapters/sequel.rb', line 395

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