Hi,
I'm trying to make a new Redis driver for Mojolicious that makes sense. Me and Marcus Ramberg has been maintaining Mojo::Redis, but I see some issues with the API:
* No blocking support
* Really poor error handling
* Trying to be clever with BLPOP and SUBSCRIBE, using an overloaded on() method
* Some really weird bugs that that I can't seem to figure out (Got one project at work which fail on random)
* Public methods that is confusing: connect(), connected(), disconnect() (?), protocol_redis() and timeout()
# What I need help with
1. Look if the API makes sense.
2. Look at the code to see if it makes sense.
3. Tell me when something is awkward or plain wrong.
4. Figure out if ->execute() makes sense and/or if it could be replace with something "nicer"
I often do many commands at once, so what execute() fix is this:
Mojo::IOLoop->delay(
sub {
my ($delay) = @_;
$redis->get(foo => $delay->begin);
$redis->get(bar => $delay->begin);
$redis->get(baz => $delay->begin);
},
sub {
my ($delay, $foo_err, $foo, $bar_err, $bar, $baz_err, $baz) = @_;
# ^ ONE MILLION ARGUMENTS!!
},
);
5. Does it make sense for one $redis object to have multiple connections to the database?
This is one of the things I built in to the new module: blpop(), subscribe(), ... will make a new connection to the database instead of user of the module need to remember which method is blocking or take over the connection. But does it really make sense?
6. I need a method for UNSUBSCRIBE
The module inherit from Mojo::EventEmitter, so I can't really use the unsubscribe() method to UNSUBSCRIBE from channels. Got an idea for an alternative way, or some fancy hack to make it work with unsubscribe()? I've been considering $redis->unsubscribe(message => $channel_name); but it kind of breaks the signature.
7. Do Mojo::Redis2 really need "encoding" attribute?
Why isn't this always UTF-8? I don't get the encoding attribute, but I kept it because of legacy from the other redis modules.
8. What do you think about pipelined()?
9. ???
# What is done (might be redesigned though)
* I got basic redis methods working blocking and non-blocking
* I got (p)subscribe methods working and (p)message events
* I got pipelining working.