How it all fits together
During module load, we construct a bunch of methods that are really just curried functions creating instances of the various Request classes and inserts them into the Memcached::Client namespace.
When you make a request, things go like this:
$client-
get> calls the anonymous subroutine returned that was returned when M::C::Request::Get->generate (which, due to inheritance, is M::C::Request->generate) was called.
The anonymous sub looks for the Memcached::Client object as its first parameter, uses the remainder as arguments for its command. The command that was curried into the subroutine is used to construct a hashref that will become the request object.
The last argument to the subroutine is examined. If it was something we can use as a callback, it is stored, and we assume that we will not be obliged to wait on a condvar in order for the request to get processed---otherwise we create the aforementioned condvar and mark ourselves as needing to wait.
We then hand the rest of our arguments to the ->init routine, which is supposed to verify the object's arguments and otherwise get it ready for submission. If it does not return a true value, it is assumed that the object is invalid for submission.
For a single-request object, this will almost always be just copying the arguments into the object, and verifying that necessary arguments are present, and c
For a multi-request object, this will involve
creates an object in the
M::C::Request::Get class that has a command of 'get'. The client then
iterates over the object's 'submit' method, taking the resulting , a
reference to the Memcached::Client object, and all of your arguments.
During construction, this object queues itself to the correct server (based on the hash of the key you passed in). And there it sits.
The connection object works its way through its queue (if there's nothing else in the queue when you add a new request, it will be handled immediately, but that's just an optimization) and comes to your request object.
It calls the ->run method on your request object, passing it a reference to itself.
The ->run method