Class: DistributedTrie::KvsBase

Inherits:
KvsIf
  • Object
show all
Defined in:
lib/distributedtrie/kvs/base.rb

Overview

pure hash implementation

Direct Known Subclasses

KvsDbm, KvsMemcache, KvsRedis, KvsTc

Instance Method Summary collapse

Methods inherited from KvsIf

#_getInternal, #delete, #initialize

Constructor Details

This class inherits a constructor from DistributedTrie::KvsIf

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


53
# File 'lib/distributedtrie/kvs/base.rb', line 53

def enabled?()  true  end

#get(key, fallback = false) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/distributedtrie/kvs/base.rb', line 44

def get( key, fallback = false )
  val = @db[ key ]
  if val
    val.force_encoding("UTF-8")
  else
    fallback
  end
end

#put!(key, value, timeout = 0) ⇒ Object



40
41
42
# File 'lib/distributedtrie/kvs/base.rb', line 40

def put!( key, value, timeout = 0 )
  @db[ key.force_encoding("ASCII-8BIT") ] = value.force_encoding("ASCII-8BIT")
end