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.

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.



403
404
405
406
407
408
# File 'lib/moneta/adapters/sequel.rb', line 403

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.



422
423
424
425
426
427
428
429
# File 'lib/moneta/adapters/sequel.rb', line 422

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.



396
397
398
399
400
401
# File 'lib/moneta/adapters/sequel.rb', line 396

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.



410
411
412
413
414
415
416
417
418
419
420
# File 'lib/moneta/adapters/sequel.rb', line 410

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.



391
392
393
394
# File 'lib/moneta/adapters/sequel.rb', line 391

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