From 74f09579425ad6060edc98c31b7781b57c5fecde Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 22 Mar 2009 09:22:39 +0000 Subject: [PATCH] dbsize git-svn-id: svn+ssh://llin/home/dpavlin/private/svn/Redis@17 447b33ff-793d-4489-8442-9bea7d161be5 --- lib/Redis.pm | 12 ++++++++++++ t/01-Redis.t | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Redis.pm b/lib/Redis.pm index 745d9ad..a2b8647 100644 --- a/lib/Redis.pm +++ b/lib/Redis.pm @@ -237,6 +237,18 @@ sub rename { _sock_ok(); } +=head2 dbsize + + my $nr_keys = $r->dbsize; + +=cut + +sub dbsize { + my ( $self ) = @_; + print $sock "DBSIZE\r\n"; + _sock_result(); +} + =head1 AUTHOR Dobrica Pavlinusic, C<< >> diff --git a/t/01-Redis.t b/t/01-Redis.t index ff2ee30..242a863 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 52; +use Test::More tests => 53; use lib 'lib'; @@ -75,4 +75,7 @@ ok( $o->exists( 'test-renamed' ), 'exists test-renamed' ); eval { $o->rename( 'test-decrby', 'test-renamed', 1 ) }; ok( $@, 'rename to existing key' ); +ok( my $nr_keys = $o->dbsize, 'dbsize' ); +diag "dbsize: $nr_keys"; + ok( $o->quit, 'quit' ); -- 2.20.1