Class: Moneta::Adapters::HBase

### Home Classes Methods

### In Files

- lib/moneta/adapters/hbase.rb

### Parent

Object

### Methods

- ::new
- #clear
- #close
- #delete
- #increment
- #key?
- #load
- #store

### Included Modules

- Moneta::Defaults

### Files

- LICENSE

### Class/Module Index

Quicksearch

- Moneta
- Moneta::Adapters
- Moneta::Adapters::ActiveRecord
- Moneta::Adapters::Cassandra
- Moneta::Adapters::Client
- Moneta::Adapters::Cookie
- Moneta::Adapters::Couch
- Moneta::Adapters::DBM
- Moneta::Adapters::DataMapper
- Moneta::Adapters::DataMapper::Store
- Moneta::Adapters::Daybreak
- Moneta::Adapters::File
- Moneta::Adapters::Fog
- Moneta::Adapters::GDBM
- Moneta::Adapters::HBase
- Moneta::Adapters::KyotoCabinet
- Moneta::Adapters::LMDB
- Moneta::Adapters::LRUHash
- Moneta::Adapters::LRUHash::Entry
- Moneta::Adapters::LevelDB
- Moneta::Adapters::LocalMemCache
- Moneta::Adapters::MemcachedDalli
- Moneta::Adapters::MemcachedNative
- Moneta::Adapters::Memory
- Moneta::Adapters::Mongo
- Moneta::Adapters::Null
- Moneta::Adapters::PStore
- Moneta::Adapters::Redis
- Moneta::Adapters::RestClient
- Moneta::Adapters::Riak
- Moneta::Adapters::SDBM
- Moneta::Adapters::Sequel
- Moneta::Adapters::Sqlite
- Moneta::Adapters::TDB
- Moneta::Adapters::TokyoCabinet
- Moneta::Adapters::TokyoTyrant
- Moneta::Adapters::YAML
- Moneta::Builder
- Moneta::Cache
- Moneta::Cache::DSL
- Moneta::CreateSupport
- Moneta::Defaults
- Moneta::Defaults::ClassMethods
- Moneta::Expires
- Moneta::ExpiresSupport
- Moneta::HashAdapter
- Moneta::IncrementSupport
- Moneta::Lock
- Moneta::Logger
- Moneta::Logger::Format
- Moneta::Mutex
- Moneta::OptionMerger
- Moneta::OptionSupport
- Moneta::Pool
- Moneta::Proxy
- Moneta::Semaphore
- Moneta::Server
- Moneta::Shared
- Moneta::Stack
- Moneta::Stack::DSL
- Moneta::SynchronizePrimitive
- Moneta::Transformer
- Moneta::Transformer::Helper
- Moneta::Utils
- Moneta::WeakCreate
- Moneta::WeakIncrement
- Moneta::Wrapper
- Rack
- Rack::Cache
- Rack::Cache::EntityStore
- Rack::Cache::EntityStore::MONETA
- Rack::Cache::EntityStore::Moneta
- Rack::Cache::MetaStore
- Rack::Cache::MetaStore::MONETA
- Rack::Cache::MetaStore::Moneta
- Rack::Cache::MonetaResolver
- Rack::MonetaCookies
- Rack::MonetaRest
- Rack::MonetaStore
- Rack::Session
- Rack::Session::Moneta
- ActionDispatch
- ActionDispatch::Session
- ActionDispatch::Session::MonetaStore
- ActiveSupport
- ActiveSupport::Cache
- ActiveSupport::Cache::MonetaStore

No matching classes.

# Moneta::Adapters::HBase

HBase thrift backend @api public

### Attributes

backend[R]

### Public Class Methods

new(options = {}) click to toggle source

@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

### Public Instance Methods

clear(options = {}) click to toggle source

(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

close() click to toggle source

(see Proxy#close)

    # File lib/moneta/adapters/hbase.rb, line 77
    def close
      @backend.close
      nil
    end

delete(key, options = {}) click to toggle source

(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

increment(key, amount = 1, options = {}) click to toggle source

(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

key?(key, options = {}) click to toggle source

(see Proxy#key?)

    # File lib/moneta/adapters/hbase.rb, line 36
    def key?(key, options = {})
      @table.get(key, @column).first != nil
    end

load(key, options = {}) click to toggle source

(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

store(key, value, options = {}) click to toggle source

(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

[Validate]

Generated with the Darkfish Rdoc Generator 2.