Object
HBase thrift backend @api public
@param [Hash] options @option options [String] :host ('127.0.0.1') Server host name @option options [Integer] :port (9090) Server port @option options [String] :table ('moneta') Table name @option options [String] :column_family ('moneta') Column family @option options [String] :column ('value') Column @option options [::HBaseRb::Client] :backend Use existing backend instance
# File lib/moneta/adapters/hbase.rb, line 24 def initialize(options = {}) options[:column] ||= 'value' options[:table] ||= 'moneta' cf = (options[:column_family] || 'moneta') @column = "#{cf}:#{options[:column]}" @backend = options[:backend] || HBaseRb::Client.new(options[:host] || '127.0.0.1', options[:port] || '9090') @backend.create_table(options[:table], cf) unless @backend.has_table?(options[:table]) @table = @backend.get_table(options[:table]) end
(see Proxy#clear)
# File lib/moneta/adapters/hbase.rb, line 69 def clear(options = {}) @table.create_scanner do |row| @table.delete_row(row.row) end self end
(see Proxy#close)
# File lib/moneta/adapters/hbase.rb, line 77 def close @backend.close nil end
(see Proxy#delete)
# File lib/moneta/adapters/hbase.rb, line 61 def delete(key, options = {}) if value = load(key, options) @table.delete_row(key) value end end
(see Proxy#increment)
# File lib/moneta/adapters/hbase.rb, line 53 def increment(key, amount = 1, options = {}) result = @table.atomic_increment(key, @column, amount) # HACK: Throw error if applied to invalid value Utils.to_int(load(key)) if result == 0 result end
(see Proxy#key?)
# File lib/moneta/adapters/hbase.rb, line 36 def key?(key, options = {}) @table.get(key, @column).first != nil end
(see Proxy#load)
# File lib/moneta/adapters/hbase.rb, line 41 def load(key, options = {}) cell = @table.get(key, @column).first cell && unpack(cell.value) end
(see Proxy#store)
# File lib/moneta/adapters/hbase.rb, line 47 def store(key, value, options = {}) @table.mutate_row(key, @column => pack(value)) value end
Generated with the Darkfish Rdoc Generator 2.