App-redisp

 view release on metacpan or  search on metacpan

lib/App/redisp.pm  view on Meta::CPAN

      my $type = $op->name eq 'gvsv' ? 'sv' :
      $op->name eq 'aelemfast' ? 'av' :
      ($op->next->name =~ /2(.*)/)[0];

      # B::Concise::concise_op was helpful here
      if($type) {
        my $idx = $op->isa("B::SVOP") ? $op->targ : $op->padix;

        my $sv;
        if($op->isa("B::PADOP") || !${$op->sv}) {
          $sv = (($cv->PADLIST->ARRAY)[1]->ARRAY)[$idx];
        } else {
          $sv = $op->sv;
        }
        my $gv_name = $sv->can("NAME") ? $sv->NAME : $sv->PV;
        push @vars, [$gv_name, $type] if $gv_name;
      }
    }
  } while $op = $op->next and $op->isa("B::OP");

  return @vars;
}




=pod

=head1 NAME

App::redisp - Perl redis shell

=head1 VERSION

version 0.13

=head1 SYNOPSIS

 $ redisp
 localhost> keys "foo*"
 "foobar", "food"
 localhost> set foobarbaz, 12
 "OK"

 # Or in perl style
 localhost> $foobar
 10

 # Actually these next ones aren't implemented yet...
 localhost> .encoding utf-8
 localhost> .server xxx
 localhost> .reconnect
 localhost> .output json

=head1 DESCRIPTION

Redis and Perl share similar data types, therefore I thought it would be useful
to have a Redis shell interface that appears to behave as Perl. This is a Perl
Read-Eval-Print Loop (REPL) that happens to understand Redis.

The use of Redis aims to be transparent, you just use a variable like C<$foo>
and it will be read or saved to Redis. For a temporary variable that is only visible to Perl use C<my $foo>.

=for Pod::Coverage eval_with_lexicals host port debug eval BUILD run serialize usage

=head1 USAGE

 redisp [--help] [--server=host] [--port=port] [--encoding=encoding]
   [--serialize=serializer]

=head1 OPTIONS

=over 4

=item * B<--help>

This document.

=item * B<--server>

Host to connect to Redis on.

=item * B<--port>

Port to connect to Redis on.

=item * B<--encoding>

Encoding to use with Redis, B<UTF-8> is recommended (but the default is none).

=item * B<--serialize>

Serializer to use, see the L<Tie::Redis> documentation for details on supported
serializers and the limitations.

=back

=head1 LIMITATIONS

The main noticable thing is common key naming styles in Redis such as
C<"foo-bar"> or C<"foo:bar"> require quoting on the Perl side. For example to
access a top level key of foo:bar you need to access C<${"foo:bar"}>.

In Redis a key has one type; in Perl a glob reference may have HASH, ARRAY,
SCALAR, etc values. This application makes Perl match the Redis behaviour, it's
invalid to use more than one type at a particular name. The error will be:
C<ERR Operation against a key holding the wrong kind of value>.

Due to the way this works it's impossible to use symbolic references (e.g.
C<${"foo$a"}>), your code needs to reference top level keys it uses at compile
time.

=head1 EXAMPLES

Yet more examples, because the synopsis section was getting sort of big.

C<info> is a command that returns a hash, so to grab something like the version
you can do this:

 localhost> info
 [returns big hash]



( run in 0.538 second using v1.01-cache-2.11-cpan-2398b32b56e )