Skip to content

Commit

Permalink
sort
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@47 447b33ff-793d-4489-8442-9bea7d161be5
  • Loading branch information
dpavlin committed Mar 23, 2009
1 parent baf5779 commit f5a339e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/Redis.pm
Expand Up @@ -536,6 +536,17 @@ sub flushall {
$self->_sock_send_ok('flushall');
}

=head1 Sorting
$r->sort("key BY pattern LIMIT start end GET pattern ASC|DESC ALPHA');
=cut

sub sort {
my ( $self, $sort ) = @_;
$self->_sock_result_bulk_list( "SORT $sort" );
}

=head1 AUTHOR
Dobrica Pavlinusic, C<< <dpavlin at rot13.org> >>
Expand Down
10 changes: 9 additions & 1 deletion t/01-Redis.t
Expand Up @@ -3,7 +3,7 @@
use warnings;
use strict;

use Test::More tests => 95;
use Test::More tests => 102;

use lib 'lib';

Expand Down Expand Up @@ -162,6 +162,14 @@ ok( $o->exists( 'foo' ), 'exists' );
ok( $o->flushdb, 'flushdb' );
cmp_ok( $o->dbsize, '==', 0, 'empty' );

diag "Sorting";

ok( $o->lpush( 'test-sort', $_ ), "put $_" ) foreach ( 1 .. 4 );
cmp_ok( $o->llen( 'test-sort' ), '==', 4, 'llen' );

is_deeply( [ $o->sort( 'test-sort' ) ], [ 1,2,3,4 ], 'sort' );
is_deeply( [ $o->sort( 'test-sort DESC' ) ], [ 4,3,2,1 ], 'sort DESC' );

diag "Connection handling";

ok( $o->quit, 'quit' );

0 comments on commit f5a339e

Please sign in to comment.