Class: Enygma::Adapters::MemcacheAdapter

Inherits:
AbstractAdapter show all
Defined in:
lib/enygma/adapters/memcache.rb

Instance Attribute Summary

Attributes inherited from AbstractAdapter

#datastore

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#get_attribute

Instance Method Details

#connect!(datastore) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/enygma/adapters/memcache.rb', line 8

def connect!(datastore)
  @datastore = case datastore
  when MemCache
    datastore
  else
    MemCache.new(datastore)
  end
end

#query(args = {}) ⇒ Object



17
18
19
20
# File 'lib/enygma/adapters/memcache.rb', line 17

def query(args = {})
  ids = args.has_key?(:key_prefix) ? args[:ids].collect {|i| "#{args[:key_prefix]}#{i}"} : args[:ids]
  @datastore.get_multi(*ids).values
end