Class: DistributedTrie::KvsMemcache

Inherits:
KvsBase show all
Defined in:
lib/distributedtrie/kvs/memcache.rb

Overview

Memcache client implementation

Instance Method Summary collapse

Methods inherited from KvsBase

#enabled?, #get

Methods inherited from KvsIf

#_getInternal, #delete, #get

Constructor Details

#initialize(host = "localhost", port = "1978") ⇒ KvsMemcache

Returns a new instance of KvsMemcache.



41
42
43
44
45
46
# File 'lib/distributedtrie/kvs/memcache.rb', line 41

def initialize( host = "localhost", port = "1978" )
  @db = MemCache.new(
                     host + ":" + port,
                     :connect_timeout => 1000.0,
                     :timeout => 1000.0 )
end

Instance Method Details

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



48
49
50
# File 'lib/distributedtrie/kvs/memcache.rb', line 48

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