Sha256: 3ecf41aabbb52d8ac598bced1cb7a268428ebb49d03c8241147c2ec7688a4d0c

Contents?: true

Size: 522 Bytes

Versions: 2

Compression:

Stored size: 522 Bytes

Contents

require 'memcache'

module Enygma
  module Adapters
    
    class MemcacheAdapter < Enygma::Adapters::AbstractAdapter
      
      def connect!(datastore)
        @datastore = case datastore
        when MemCache
          datastore
        else
          MemCache.new(datastore)
        end
      end
      
      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
      
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sander6-enygma-0.1.0 lib/enygma/adapters/memcache.rb
sander6-enygma-0.1.1 lib/enygma/adapters/memcache.rb