Class: EventMachine::Protocols::Memcache::Connection
- Inherits:
-
Connection
- Object
- Connection
- EventMachine::Protocols::Memcache::Connection
- Includes:
- Connectable
- Defined in:
- lib/evented_memcache_client/connection.rb
Overview
Implements a memcache protocol connection.
Direct Known Subclasses
Constant Summary
Constants included from Connectable
EventMachine::Protocols::Memcache::Connectable::ALL_MESSAGES, EventMachine::Protocols::Memcache::Connectable::ARGS_AND_BODY_MESSAGES, EventMachine::Protocols::Memcache::Connectable::ARG_AND_BODY_MESSAGES, EventMachine::Protocols::Memcache::Connectable::ARG_MESSAGES, EventMachine::Protocols::Memcache::Connectable::BODY_MESSAGES, EventMachine::Protocols::Memcache::Connectable::HEADER_REGEX, EventMachine::Protocols::Memcache::Connectable::NO_ARG_MESSAGES
Instance Method Summary collapse
-
#initialize(*args) ⇒ Connection
constructor
Create a new connection.
Methods included from Connectable
#connection_completed, #handle, #io_per_sec, #parse_header, #parse_incoming_data, #post_init, #receive_data, #receive_message, #remote_endpoint, #set_handler, #start_closing, #to_s, #unbind
Methods included from Sender
#book_it, #cas, #delete, #get, #send_to_peer, #stats, #value
Constructor Details
#initialize(*args) ⇒ Connection
Create a new connection. Args are a hash of callbacks (or a Module – see Connectable#set_handler).
Note that when you’re using EventMachine, you won’t be calling Connection::new yourself - EM does it for you when a connection is established.
Eg:
callbacks = {
:open => Proc.new { |conn|
conn.set(:key => 'x', :data => Time.now.to_s)
},
:stored => Proc.new { |conn, data, args|
puts "Stored a value"
EventMachine::stop
},
}
EventMachine::run {
EventMachine::connect('127.0.0.1',
12345,
EventMachine::Protocols::Memcache::Connection,
callbacks)
}
64 65 66 67 68 |
# File 'lib/evented_memcache_client/connection.rb', line 64 def initialize(*args) super(*args) return if !args || args.empty? set_handler(args[0]) end |