public
Last active — forked from und3f/Author.pm

  • Download Gist
Author.pm
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
package NoticeBackend::Author;
use Mojo::Base 'Mojolicious::Controller';
 
use 5.12.0;
use warnings;
use utf8;
 
use MojoX::Redis;
use Mojo::IOLoop;
 
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->ioloop(Mojo::IOLoop->new);
$redis->get( $user_query => sub {
my ($redis, $res) = @_;
 
$data_out = $res->[0];
$redis->stop;
});
$redis->start;
$self->render( text => "|$data_out|" );
};
 
1;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.