Giter Site home page Giter Site logo

mojo-redis's Introduction

NAME

Mojo::Redis - DEPRECATED Redis client

DESCRIPTION

Mojo::Redis is replaced by Mojo::Redis2.

THIS MODULE IS NO LONGER MAINTAINED AND WILL BE REPLACED BY A COMPLETELY NEW API DURING 2015.

The new API is available in Mojo::Redis2.

Some time during 2015, this module will be completely replaced by the code from Mojo::Redis2.

YOU SHOULD NOT USE THIS MODULE. THE RISK OF MEMORY LEAKS AND MISSING OUT ON ERRORS IS INEVITABLE.

The exact date for replacement is not yet set, but when it's replaced your existing Mojo::Redis code will break.

REPLACE Mojo::Redis WITH Mojo::Redis2 NOW.

SUPPORT

There's no support for this module.

AUTHOR

Sergey Zasenko, [email protected].

Forked from MojoX::Redis and updated to new IOLoop API by Marcus Ramberg [email protected] and Jan Henning Thorsen [email protected].

COPYRIGHT AND LICENSE

Copyright (C) 2010-2011, Sergey Zasenko (C) 2012, Marcus Ramberg

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

mojo-redis's People

Contributors

kanatohodets avatar marcusramberg avatar niczero avatar und3f avatar zpmorgan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

mojo-redis's Issues

'close' event duplication on subscriptions

#!/usr/bin/env perl
#
use Mojo::Redis;
use Modern::Perl;
use 5.14.0;

my $s = Mojo::Redis->new(timeout => 1);
$s->subscribe('foo', sub{
   my ($redis,$res) = @_;
   $redis->on(close => sub{say 'foo'});;
});
$s->subscribe('bar', sub{
   my ($redis,$res) = @_;
   $redis->on(close => sub{say 'bar'});;
});
$s->subscribe('baz', sub{
   my ($redis,$res) = @_;
   $redis->on(close => sub{say 'baz'});;
});

$s->ioloop->start();
__END__

expected output (in no order, necessarily):
foo
bar
baz

Got output:
foo
bar
baz
foo
bar
baz
foo
bar
baz

Add "empty_queue" event

Could be nice to have an "idle" or "empty_queue" event which is triggered when the internal callback queue is empty.

I will implement it, if it's a good idea.

Live auth tests fail

https://gist.github.com/6669397

stderr:

#   Failed test 'could not login to redis'
#   at t/auth.t line 22.
#                   undef
#     doesn't match '(?^:^ERR.*AUTH)'
# undef
Use of uninitialized value $this in pattern match (m//) at t/auth.t line 23.

#   Failed test 'could not select db 123 on redis'
#   at t/auth.t line 23.
#                   undef
#     doesn't match '(?^:^ERR.*DB)'
# undef
# Looks like you failed 2 tests of 5.
# close
# close
Timeout at /Users/marcus/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/Mojo/EventEmitter.pm line 42.
# close
Failed 1/10 test programs. 2/85 subtests failed.
make[1]: *** [test_dynamic] Error 255
make: *** [disttest] Error 2

Add clone() method

I want a clone() method to duplicate the object before executing BLPOP and similar blocking operations.

my $blocking = $redis->clone;
$blocking->blpop("foo", 0, sub { ... });

Another idea would be to allow blpop to create a "clone" internally in Mojo::Redis instead. That could probably be even smoother actually.

What do you think @marcusramberg ?

So the problem I want to solve is to add a better API for still being able to use the origin $redis even if some of the scheduled commands are blocking new commands.

Please assign back to me after we have decided what to do.

Crash on connection close using blpop

Hi,

Here is a small worker program that consume items on a Redis queue using blpop.

#!/usr/bin/env perl

use Mojo::Base -strict;
use Mojo::Redis;

my $redis = Mojo::Redis->new;

$redis->on(blpop => 'test', sub {
    my ($redis, $err, $msg, $chan) = @_;
    warn $err if $err;
    say $msg;
});

$redis->ioloop->start;

When I start this program and stop redis-server, it dies with the following error:
Can't use an undefined value as an ARRAY reference at /usr/local/share/perl/5.18.2/Mojo/Redis.pm line 407.
Use of uninitialized value $msg in say at ./simple.pl line 11.

Btw, I had the same error in a Mojo::Lite application when I was using blpop outside of a Mojo::IOLoop->delay and stopping it with ctrl+c.

It seems empty blpop events are emitted on connection close.

Mojo::Redis error on starting under morbo

Here is simple script "a.pl"

#!/usr/bin/env perl
use Mojolicious::Lite;
use Mojo::Redis;

my $pub = Mojo::Redis->new;
my $sub = $pub->subscribe('test');

app->start;

I start it via:

MOJO_REDIS_DEBUG=1 morbo ./a.pl

Then I receive the following output with an error:

[Sun Mar 17 16:11:00 2013] [info] Listening at "http://*:3000".
Server available at http://127.0.0.1:3000.
REDIS[3cb558e9bbf36b35166300d998b8c122] <<< ['*2','$9','SUBSCRIBE','$4','test','']
Use of uninitialized value in join or string at /home/dmol/development/perl/lib/lib/perl5/Mojo/Redis.pm line 115.
REDIS[] >>> ['*3','$9','subscribe','$4','test',':1','']
Event "error" failed: Can't call method "_inform_queue" on unblessed reference at /home/dmol/development/perl/lib/lib/perl5/Mojo/Redis.pm line 131.

But when I start it in pre-fork mode no error is generated:

MOJO_REDIS_DEBUG=1  ./a.pl prefork

Versions: perl: v5.16.2, Mojolicious: 3.90, Mojo::Redis: 0.9903, redis: 2.4.10

When morbo terminate , counld not call redis callbacks.

Hi,
I used Mojo::Redis and Mojolicious websocket.
When I terminate morbo by CTRL+C;
HDEL callback didnot called.
When broser ws.close() called , this callback did called.
I want to clean up , redis object when morbo terminate.

    $self->on(finish => sub {

      $redis->hdel(
        channel => "test" => sub {
        my ($redis, $ret) = @_;
        ・・・

Mojolicious 2.10 issue

Seems like minimal Mojolicious version, specified in Makefile.PL, is wrong:
% REDIS_SERVER=localhost prove t/
Can't locate object method "client" via package "Mojo::IOLoop" at /home/und3f/dev/mojox-redis/lib/Mojo/Redis.pm line 143.

Looks like your test exited with 255 before it could output anything.

t/leak.t ...............
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 4/4 subtests
t/pod.t ................ skipped: Test::Pod 1.14 required for this test!
Can't locate object method "server" via package "Mojo::IOLoop" at t/redis.t line 37.

Looks like you planned 10 tests but ran 1.

Looks like your test exited with 29 just after 1.

t/redis.t ..............
Dubious, test returned 29 (wstat 7424, 0x1d00)
Failed 9/10 subtests
Can't locate object method "client" via package "Mojo::IOLoop" at /home/und3f/dev/mojox-redis/lib/Mojo/Redis.pm line 143.

Looks like you planned 15 tests but ran 2.

Looks like your test exited with 255 just after 2.

t/redis_live.t .........
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 13/15 subtests
Can't locate object method "client" via package "Mojo::IOLoop" at /home/und3f/dev/mojox-redis/lib/Mojo/Redis.pm line 143.

Looks like you planned 3 tests but ran 2.

Looks like your test exited with 255 just after 2.

t/redis_live_multi.t ...
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 1/3 subtests
t/redis_live_pubsub.t .. ok

Test Summary Report

t/leak.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 4 tests but ran 0.
t/redis.t (Wstat: 7424 Tests: 1 Failed: 0)
Non-zero exit status: 29
Parse errors: Bad plan. You planned 10 tests but ran 1.
t/redis_live.t (Wstat: 65280 Tests: 2 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 15 tests but ran 2.
t/redis_live_multi.t (Wstat: 65280 Tests: 2 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 3 tests but ran 2.
Files=6, Tests=8, 2 wallclock secs ( 0.03 usr 0.00 sys + 0.53 cusr 0.03 csys = 0.59 CPU)
Result: FAIL

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.