Skip to content

Instantly share code, notes, and snippets.

@Meettya
Created February 25, 2011 21:03
Show Gist options
  • Save Meettya/844488 to your computer and use it in GitHub Desktop.
Save Meettya/844488 to your computer and use it in GitHub Desktop.
MojoX::Redis example
package NoticeBackend::Author;
use Mojo::Base 'Mojolicious::Controller';
use 5.12.0;
use warnings;
use utf8;
use MojoX::Redis;
my $redis = MojoX::Redis->new(server => '192.168.1.20:6379');
my ($redis_out);
sub get{
my $self = shift;
my $user_query = $self->req->is_xhr ?
$self->req->json->{'name'} : $self->param('name');
my $callback_name = $self->req->is_xhr ?
$self->req->json->{'callback'} : $self->param('callback');
my $data_out;
$redis->get( $user_query => sub {
my ($redis, $res) = @_;
$data_out = $res->[0];
print "Value of ' $user_query ' is $res->[0]\n";
});
say 'before render';
$self->render( text => "|$data_out|" );
say 'after render';
};
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment