From: miker Date: Thu, 24 Feb 2005 13:14:26 +0000 (+0000) Subject: added nondestructive (queue|stack).peek.all interface for grabbing the entire slot... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=aaddf63777cc331d43314a96d195453d21bbb81f;p=working%2FOpenSRF.git added nondestructive (queue|stack).peek.all interface for grabbing the entire slot without removing anything. the base registered methods are streaming, so a ".atomic" version is generated by the system. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@100 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/perlmods/OpenSRF/Application/Persist.pm b/src/perlmods/OpenSRF/Application/Persist.pm index be72d96..cc4c092 100644 --- a/src/perlmods/OpenSRF/Application/Persist.pm +++ b/src/perlmods/OpenSRF/Application/Persist.pm @@ -201,6 +201,38 @@ __PACKAGE__->register_method( ); +sub peek_slot { + my $self = shift; + my $client = shift; + + my $name = shift or do { + throw OpenSRF::EX::WARN ("No slot name specified!"); + }; + my $name_id = _get_name_id($name); + + my $order = 'ASC'; + $order = 'DESC' if ($self->api_name =~ /stack/o); + + my $values = $dbh->selectall_arrayref("SELECT value FROM storage WHERE name_id = ? ORDER BY id $order;", {}, $name_id); + + $client->respond( JSON->JSON2perl( $_->[0] ) ) for (@$values); + + return undef; +} +__PACKAGE__->register_method( + api_name => 'opensrf.persist.queue.peek.all', + method => 'peek_slot', + argc => 1, + stream => 1, +); +__PACKAGE__->register_method( + api_name => 'opensrf.persist.stack.peek.all', + method => 'peek_slot', + argc => 1, + stream => 1, +); + + sub store_size { my $self = shift; my $client = shift;