Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/cpan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,25 @@ jobs:

perlcritic:
uses: PerlToolsTeam/github_workflows/.github/workflows/cpan-perlcritic.yml@main

check-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Set up perl
uses: shogo82148/actions-setup-perl@v1

- name: Perl version
run: perl -V

- name: Configure with Makefile.PL
id: configure-with-eumm
run: perl Makefile.PL

- name: Install Perl::Tidy
run: cpanm --notest Perl::Tidy

- name: Check formatting
run: make check-format

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ pm_to_blib
inc/
MYMETA.*
/Protocol-Redis*.tar.gz
/README
*.bak
43 changes: 43 additions & 0 deletions .perltidyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# General behavinor
--standard-error-output
--backup-and-modify-in-place

# Indentation
--indent-columns=4
--continuation-indentation=2

# Line length
--maximum-line-length=78
--maximum-consecutive-blank-lines=4

# Vertical tightness
--vertical-tightness=0

# Horizontal tightness
--paren-tightness=2
--brace-tightness=2
--square-bracket-tightness=2
--block-brace-tightness=1

# Stack tokens
--stack-opening-tokens
#--stack-closing-tokens

# Other style
#--cuddled-else
--opening-token-right
--closing-token-indentation=0

--nospace-for-semicolon
--nooutdent-long-lines

--want-break-before="% + - * / x != == >= <= =~ < > | & **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="

# Comments

# troublesome for commented out code
--nohanging-side-comments

# block comments may only be indented if they have some space characters before the #
--indent-spaced-block-comments

13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
This file documents the revision history for Perl extension Protocol::Redis

2.0002 11.02.2026 00:00:00
- Improve README, format code.

2.0001 04.02.2026 00:00:00
- Test and fix encoding 0 as a double in RESP3 (Grinnz).

Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
^Makefile$
^\.git
^MANIFEST\.
^README.pod$
^scripts/.*
^.perltidyrc$
\.bak$
\.swp$
MYMETA
Expand Down
52 changes: 39 additions & 13 deletions Makefile.PL
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use 5.008001;

use strict;
use warnings;

use ExtUtils::MakeMaker;

WriteMakefile(
Expand All @@ -14,24 +14,50 @@ WriteMakefile(

META_MERGE => {
dynamic_config => 0,
'meta-spec' => { version => 2 },
'meta-spec' => {version => 2},
resources => {
license => [ 'http://dev.perl.org/licenses/' ],
license => ['http://dev.perl.org/licenses/'],
repository => {
type => 'git',
url => 'https://github.com/und3f/protocol-redis.git',
web => 'https://github.com/und3f/protocol-redis',
type => 'git',
url => 'https://github.com/und3f/protocol-redis.git',
web => 'https://github.com/und3f/protocol-redis',
},
bugtracker => { web => 'https://github.com/und3f/protocol-redis/issues' },
bugtracker =>
{web => 'https://github.com/und3f/protocol-redis/issues'},
},
prereqs => {
develop => {
requires => {
'Pod::Readme::Brief' => 0,
'Pod::Simple::JustPod' => 0,
}
}
},
},

MIN_PERL_VERSION => '5.008001',
PREREQ_PM => {
'Carp' => 0,
PREREQ_PM => {
'Carp' => 0,
'Math::BigInt' => 0,
'Test::More' => '0.94',
'Test::More' => '0.94',
},
test => {TESTS => 't/*.t'},

test => {TESTS => 't/*.t'},
);

sub MY::postamble {
return <<'MAKEFILE';
create_distdir: README

README: scripts/create-readme.pl

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this will be run on make dist, I suggest adding Pod::Readme::Brief to develop requires in META_MERGE (e.g. prereqs => {develop => {requires => {'Pod::Readme::Brief' => 0}}})

$(PERLRUN) $< $@

README.pod: scripts/create-readme-pod.pl
$(PERLRUN) $< $@

format:
find . -iname "*.p[ml]" -o -name "*.t" | xargs perltidy

check-format:
find . -iname "*.p[ml]" -o -name "*.t" | xargs perltidy --assert-tidy
MAKEFILE
}
7 changes: 5 additions & 2 deletions README.pod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
=pod

=head1 NAME

Protocol::Redis - Redis protocol parser/encoder with asynchronous capabilities.
Expand Down Expand Up @@ -203,7 +205,7 @@ Get parsed message or undef.
Calls callback on each parsed message.

=head2 C<encode>

my $string = $redis->encode({type => '+', data => 'test'});
$string = $redis->encode(
{type => '*', data => [
Expand All @@ -217,13 +219,13 @@ Encode data into redis message.

Get API version.


=head1 SUPPORT

=head2 IRC

#redis on irc.perl.org


=head1 DEVELOPMENT

=head2 Repository
Expand Down Expand Up @@ -259,3 +261,4 @@ Copyright (C) 2011-2026, Serhii Zasenko.
This program is free software, you can redistribute it and/or modify it under
the same terms as Perl 5.10.

=cut
62 changes: 35 additions & 27 deletions examples/benchmark.pl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Protocol::Redis::Faster;
use Protocol::Redis::Test;

my $redis = Protocol::Redis->new(api => 1);
my $redis = Protocol::Redis->new(api => 1);
my $redis_fast = Protocol::Redis::Faster->new(api => 1);

$redis->on_message(sub { });
Expand All @@ -32,64 +32,72 @@ sub encode {
# Encode multi-bulk
$redis->encode({type => '*', data => [{type => '$', data => 'test'}]});

$redis->encode(
{ type => '*',
$redis->encode({
type => '*',
data => [
{type => '$', data => 'test1'}, {type => '$', data => 'test2'}
]
}
);
);

$redis->encode({type => '*', data => []});

$redis->encode({type => '*', data => undef});

$redis->encode(
{ type => '*',
$redis->encode({
type => '*',
data => [
{type => '$', data => 'foo'},
{type => '$', data => undef},
{type => '$', data => 'bar'}
]
}
);
);
}

cmpthese(2**17, {
cmpthese(
2**17, {
'P:R:F encode' => sub { encode($redis_fast) },
'P:R encode' => sub { encode($redis) },
});
'P:R encode' => sub { encode($redis) },
}
);

my $status_message = $redis->encode({type => '+', data => 'OK'});
cmpthese(
-1,
{ 'P:R Status parse' => sub { $redis->parse($status_message) },
-1, {
'P:R Status parse' => sub { $redis->parse($status_message) },
'P:R:F Status parse' => sub { $redis_fast->parse($status_message) },
});
}
);

my $a = 'cmpthese',(
-1,
{
my $a = 'cmpthese', (
-1, {
'P:R Splitted status parse' =>
sub { $redis->parse("+OK"); $redis->parse("\r\n") },
'P:R:F Splitted status parse' =>
sub { $redis_fast->parse("+OK"); $redis->parse("\r\n") },
}
);
);

my $bulk_message = $redis->encode({type => '$', data => 'test'}) . $redis->encode({type => '$', data => undef});
cmpthese(-1, {
'Bulk parse P:R' => sub { $redis->parse($bulk_message) },
my $bulk_message = $redis->encode({type => '$', data => 'test'})
. $redis->encode({type => '$', data => undef});
cmpthese(
-1, {
'Bulk parse P:R' => sub { $redis->parse($bulk_message) },
'Bulk parse P:R:F' => sub { $redis_fast->parse($bulk_message) },
});
}
);

my $mbulk_message = $redis->encode(
{ type => '*',
my $mbulk_message = $redis->encode({
type => '*',
data =>
[{type => '$', data => 'test1'}, {type => '$', data => 'test2'}]
}
);
cmpthese(-1, {
'P:R Multi-Bulk parse' => sub { $redis->parse($mbulk_message) },
'P:R:F Multi-Bulk parse' => sub { $redis_fast->parse($mbulk_message) },
});
cmpthese(
-1, {
'P:R Multi-Bulk parse' => sub { $redis->parse($mbulk_message) },
'P:R:F Multi-Bulk parse' =>
sub { $redis_fast->parse($mbulk_message) },
}
);
Loading
Loading