| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::Async::Redis::XS; | 
| 2 |  |  |  |  |  |  | # ABSTRACT: faster version of Net::Async::Redis | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 2 |  |  | 2 |  | 266859 | use strict; | 
|  | 2 |  |  |  |  | 25 |  | 
|  | 2 |  |  |  |  | 66 |  | 
| 5 | 2 |  |  | 2 |  | 11 | use warnings; | 
|  | 2 |  |  |  |  | 4 |  | 
|  | 2 |  |  |  |  | 87 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.012'; | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 2 |  |  | 2 |  | 947 | use parent qw(Net::Async::Redis); | 
|  | 2 |  |  |  |  | 671 |  | 
|  | 2 |  |  |  |  | 11 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =head1 NAME | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | Net::Async::Redis::XS - like L but faster | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | use feature qw(say); | 
| 18 |  |  |  |  |  |  | use Future::AsyncAwait; | 
| 19 |  |  |  |  |  |  | use IO::Async::Loop; | 
| 20 |  |  |  |  |  |  | use Net::Async::Redis::XS; | 
| 21 |  |  |  |  |  |  | my $loop = IO::Async::Loop->new; | 
| 22 |  |  |  |  |  |  | $loop->add(my $redis = Net::Async::Redis::XS); | 
| 23 |  |  |  |  |  |  | await $redis->connect; | 
| 24 |  |  |  |  |  |  | await $redis->set('some-key', 'some-value'); | 
| 25 |  |  |  |  |  |  | say await $redis->get('some-key'); | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | This is a wrapper around L with faster protocol parsing. | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | It implements the L protocol code in XS for better performance, | 
| 32 |  |  |  |  |  |  | and will eventually be extended to optimise some other slow paths as well in future. | 
| 33 |  |  |  |  |  |  |  | 
| 34 |  |  |  |  |  |  | API and behaviour should be identical to L, see there for instructions. | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | =cut | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | package Net::Async::Redis::Protocol::XS { | 
| 39 | 2 |  |  | 2 |  | 643254 | use parent qw(Net::Async::Redis::Protocol); | 
|  | 2 |  |  |  |  | 5 |  | 
|  | 2 |  |  |  |  | 13 |  | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub decode { | 
| 42 | 0 |  |  | 0 |  | 0 | my ($self, $bytes) = @_; | 
| 43 | 0 |  |  |  |  | 0 | my @data = Net::Async::Redis::XS::decode_buffer($self, $$bytes); | 
| 44 | 0 |  |  |  |  | 0 | $self->item($_) for @data; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 | 2 |  |  | 2 | 0 | 502 | sub dl_load_flags { 1 } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | require DynaLoader; | 
| 51 |  |  |  |  |  |  | __PACKAGE__->DynaLoader::bootstrap(__PACKAGE__->VERSION); | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub wire_protocol { | 
| 54 | 0 |  |  | 0 | 1 |  | my ($self) = @_; | 
| 55 | 0 |  | 0 |  |  |  | $self->{wire_protocol} ||= do { | 
| 56 |  |  |  |  |  |  | Net::Async::Redis::Protocol::XS->new( | 
| 57 |  |  |  |  |  |  | handler  => $self->curry::weak::on_message, | 
| 58 |  |  |  |  |  |  | pubsub   => $self->curry::weak::handle_pubsub_message, | 
| 59 |  |  |  |  |  |  | error    => $self->curry::weak::on_error_message, | 
| 60 | 0 |  | 0 |  |  |  | protocol => $self->{protocol_level} || 'resp3', | 
| 61 |  |  |  |  |  |  | ) | 
| 62 |  |  |  |  |  |  | }; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | 1; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | =head1 AUTHOR | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | Tom Molesworth | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | with contributions from C<< PEVANS@cpan.org >>. | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | =head1 LICENSE | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | Copyright Tom Molesworth 2022-2023. Licensed under the same terms as Perl itself. | 
| 76 |  |  |  |  |  |  |  |