Added support for Redis PubSub: * support commands SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, and PUNSUBSCRIBE: * PUBLISH is a regular Redis command, already supported. * last argument of subscription changes commands must be a callback, a coderef: * for each message, the callback will be called with three parameters: * the messages data; * the topic to whom the message was sent; * the subscription that catched this message. * you can subscribe to multiple topics or topic matches with the same callback: messages to any of those topics will invoke the callback; * you can call p?subscribe() multiple times with the same topics or topic matching rules, and with different callbacks: * we will manage a single Redis subscription, and call all the callbacks per message received. * p?unsubscribe() calls require the original callback, to remove the correct subscription. Signed-off-by: Pedro Melo <melo@simplicidade.org>
Add initial support for subscriber mode: When we use any of SUBSCRIBE commands, we need to restrict the commands we can use after. Only other SUBSCRIBE, or UNSUBSCRIBE commands are valid. We added a "mode", is_subscriber, that default to 0 and will be true after we subscribe something. When is_subscriber is active, invalid commands will result in an exception. Signed-off-by: Pedro Melo <melo@simplicidade.org>
Rewrote response reading code, moved INFO and KEYS out of AUTOLOAD * response reading code uses less syscalls with big values: more speed; * multi-bulk response fixed: supports mixed items in the response, like $ and : in the same response - this happens with SUBSCRIBE messages * INFO and KEYS have their own methods now: no more if's for special cases in AUTOLOAD. Signed-off-by: Pedro Melo <melo@simplicidade.org>
Add support for Redis 2.x, and other tweaks: * send commands using the multi-bulk protocol: allows you to use binary keys and values; * keep the default of utf8 encoding, but allow for other encodings, including binary; * remove old bulk_command table: no longer used, with the new multi-bulk protocol for sending commands; * remove 'use bytes', no longer needed with the new encoding algorithm; * adjust the 'KEYS' command to also support multi-bulk responses on newer servers; * make sure bulk responses of 0 size return an empty string; * perl-ish multi-bulk response. Signed-off-by: Pedro Melo <melo@simplicidade.org>