Git Product home page Git Product logo

anyevent-hiredis's Introduction

NAME

AnyEvent::Hiredis - AnyEvent hiredis API

SYNOPSIS

use AnyEvent::Hiredis;

my $redis = AnyEvent::Hiredis->new(
    host => '127.0.0.1',
    port => 6379,
);

$redis->command( [qw/SET foo bar/], sub { warn "SET!" } );
$redis->command( [qw/GET foo/, sub { my $value = shift } );

$redis->command( [qw/LPUSH listkey value/] );
$redis->command( [qw/LPOP listkey/], sub { my $value = shift } );

# errors
$redis->command( [qw/SOMETHING WRONG/, sub { my $error = $_[1] } );

DESCRIPTION

AnyEvent::Hiredis is an AnyEvent Redis API that uses the hiredis C client library (https://github.com/antirez/hiredis).

PERFORMANCE

One reason to consider AnyEvent::Hiredis over its pure Perl counterpart AnyEvent::Redis is performance. Here's a head to head comparison of the two modules running on general purpose hardware:

Rate     ae_redis  ae_hiredis
    AnyEvent::Redis    7590/s   --        -89%
    AnyEvent::Hiredis 69400/s   814%      --

Rate here is the number of set operations per second achieved by each module. See bin/compare.pl for details.

METHODS

new

my $redis = AnyEvent::Hiredis->new; # 127.0.0.1:6379

my $redis = AnyEvent::Hiredis->new(server => '192.168.0.1', port => '6379');

command

command takes an array ref representing a Redis command and a callback. When the command has completed the callback is executed and passed the result or error.

$redis->command( ['SET', $key, 'foo'], sub {
    my ($result, $error) = @_;

    $result; # 'OK'
});

$redis->command( ['GET', $key], sub {
    my ($result, $error) = @_;

    $result; # 'foo'
});

If the Redis server replies with an error then $result will be undef and $error will contain the Redis error string. Otherwise $error will be undef.

REPOSITORY

http://github.com/wjackson/anyevent-hiredis

AUTHORS

Whitney Jackson

Jonathan Rockway

SEE ALSO

Redis, Hiredis::Async, AnyEvent::Redis

anyevent-hiredis's People

Watchers

 avatar  avatar  avatar

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.