File: em-memcache.rb

package info (click to toggle)
ruby-em-synchrony 1.0.5-3.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 572 kB
  • sloc: ruby: 3,458; sh: 37; sql: 7; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 444 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module EventMachine::Protocols::Memcache
  %w[delete get set].each do |type|
    module_eval %[
      alias :a#{type} :#{type}
      def #{type}(*params, &blk)
        f = Fiber.current
        self.a#{type}(*params) { |*cb_params| f.resume(*cb_params) }

        Fiber.yield
      end
    ]
  end

  alias :aget_hash :get_hash
  def get_hash(*keys)
    index = 0
    get(*keys).inject({}) { |h,v| h[keys[index]] = v; index += 1; h }
  end
end