From 776f1916034f293af03303fb23d65c04c62ec352 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 23 Mar 2009 11:33:21 +0000 Subject: [PATCH] save git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@48 447b33ff-793d-4489-8442-9bea7d161be5 --- lib/Redis.pm | 15 +++++++++++++++ t/01-Redis.t | 13 ++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/Redis.pm b/lib/Redis.pm index 4fc7eea..6ead5de 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -538,6 +538,8 @@ sub flushall { =head1 Sorting +=head2 sort + $r->sort("key BY pattern LIMIT start end GET pattern ASC|DESC ALPHA'); =cut @@ -547,6 +549,19 @@ sub sort { $self->_sock_result_bulk_list( "SORT $sort" ); } +=head1 Persistence control commands + +=head2 save + + $r->save; + +=cut + +sub save { + my $self = shift; + $self->_sock_send_ok( 'SAVE' ); +} + =head1 AUTHOR Dobrica Pavlinusic, C<< >> diff --git a/t/01-Redis.t b/t/01-Redis.t index 177cacf..b12e727 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 102; +use Test::More tests => 103; use lib 'lib'; @@ -15,6 +15,7 @@ ok( my $o = Redis->new(), 'new' ); ok( $o->ping, 'ping' ); + diag "Commands operating on string values"; ok( $o->set( foo => 'bar' ), 'set foo => bar' ); @@ -77,7 +78,6 @@ cmp_ok( $o->keys('key-*'), '==', $key_next + 1, 'key-*' ); is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' ); ok( my $key = $o->randomkey, 'randomkey' ); -diag "key: $key"; ok( $o->rename( 'test-incrby', 'test-renamed' ), 'rename' ); ok( $o->exists( 'test-renamed' ), 'exists test-renamed' ); @@ -86,7 +86,7 @@ eval { $o->rename( 'test-decrby', 'test-renamed', 1 ) }; ok( $@, 'rename to existing key' ); ok( my $nr_keys = $o->dbsize, 'dbsize' ); -diag "dbsize: $nr_keys"; + diag "Commands operating on lists"; @@ -162,6 +162,7 @@ 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 ); @@ -170,6 +171,12 @@ 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 "Persistence control commands"; + +ok( $o->save, 'save' ); + + diag "Connection handling"; ok( $o->quit, 'quit' ); -- 2.20.1