Perl で Redis を操作する簡単なサンプル

#!/usr/bin/env perl
use strict;
use warnings;
use Redis;

my $redis_host = '127.0.0.1';
my $redis_port = 6379;

my $redis = Redis->new(server => sprintf('%s:%d', $redis_host, $redis_port));
# Use UNIX domain socket
# my $redis = Redis->new(sock => '/path/to/socket');

$redis->set(tokyo    => 13);
$redis->set(kanagawa => 14);

if ($redis->exists('saitama')) {
    # something to do
} else {
    warn 'Not found the key.';
}

print $redis->get('tokyo'); #=> 13