NAME

App::redisp - Perl redis shell

VERSION

version 0.13

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

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 $foo and it will be read or saved to Redis. For a temporary variable that is only visible to Perl use my $foo.

USAGE

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

OPTIONS

  • --help

    This document.

  • --server

    Host to connect to Redis on.

  • --port

    Port to connect to Redis on.

  • --encoding

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

  • --serialize

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

LIMITATIONS

The main noticable thing is common key naming styles in Redis such as "foo-bar" or "foo:bar" require quoting on the Perl side. For example to access a top level key of foo:bar you need to access ${"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: 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. ${"foo$a"}), your code needs to reference top level keys it uses at compile time.

EXAMPLES

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

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

localhost> info
[returns big hash]

localhost> info->{redis_version}
"2.1.10"

Due to some commands clashing with Perl keywords you can't use them as functions. Keys and exists is something notable for this.

localhost> keys "foo*" # Special cased

localhost> sort keys "foo*" # doesn't work as you'd expect

localhost> sort redis qw(keys foo*) # does what you wanted

Pub/sub can be used, but you need to write some code yourself: XXX: This doesn't work at all yet!

localhost> subscribe foo, sub { print "@_\n" }
[prints messages, ^C stops, but you'll need to unsubscribe manually]
localhost> unsubscribe foo

BUGS

This goes quite close to the internals of Perl so there may be issues with constructs I haven't thought of. Raise bugs via http://rt.cpan.org.

The output produced by:

ANYEVENT_REDIS_DEBUG=1 DEBUG=1 redisp

for your issue would be helpful.

SEE ALSO

Tie::Redis, http://redis.io/commands, Eval::WithLexicals, Term::ReadLine::Perl (I recommend you install this or ::Gnu).

AUTHOR

David Leadbeater <dgl@dgl.cx>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by David Leadbeater.

This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Beer-ware license revision 42.