/[Redis.pre-github]/lib/Redis.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Redis.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by dpavlin, Sat Mar 21 20:20:45 2009 UTC revision 2 by dpavlin, Sat Mar 21 21:25:52 2009 UTC
# Line 3  package Redis; Line 3  package Redis;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6    use IO::Socket::INET;
7    use Data::Dump qw/dump/;
8    
9  =head1 NAME  =head1 NAME
10    
11  Redis - The great new Redis!  Redis - The great new Redis!
12    
 =head1 VERSION  
   
 Version 0.01  
   
13  =cut  =cut
14    
15  our $VERSION = '0.01';  our $VERSION = '0.01';
# Line 18  our $VERSION = '0.01'; Line 17  our $VERSION = '0.01';
17    
18  =head1 SYNOPSIS  =head1 SYNOPSIS
19    
20  Quick summary of what the module does.  Pure perl bindings for L<http://code.google.com/p/redis/>
   
 Perhaps a little code snippet.  
21    
22      use Redis;      use Redis;
23    
24      my $foo = Redis->new();      my $r = Redis->new();
25      ...  
26    
 =head1 EXPORT  
27    
 A list of functions that can be exported.  You can delete this section  
 if you don't export anything, such as for a purely object-oriented module.  
28    
29  =head1 FUNCTIONS  =head1 FUNCTIONS
30    
31  =head2 function1  =head2 new
32    
33    =cut
34    
35    our $sock;
36    my $server = '127.0.0.1:6379';
37    
38    sub new {
39            my $class = shift;
40            my $self = {};
41            bless($self, $class);
42    
43            warn "# opening socket to $server";
44    
45            $sock ||= IO::Socket::INET->new(
46                    PeerAddr => $server,
47                    Proto => 'tcp',
48            ) || die $!;
49    
50            $self;
51    }
52    
53    =head1 Connection Handling
54    
55    =head2 quit
56    
57      $r->quit;
58    
59  =cut  =cut
60    
61  sub function1 {  sub quit {
62            my $self = shift;
63    
64            close( $sock ) || warn $!;
65  }  }
66    
67  =head2 function2  =head2 ping
68    
69            $r->ping || die "no server?";
70    
71  =cut  =cut
72    
73  sub function2 {  sub ping {
74            print $sock "PING\r\n";
75            my $pong = <$sock>;
76            die "ping failed, got ", dump($pong) unless $pong eq "+PONG\r\n";
77  }  }
78    
79  =head1 AUTHOR  =head1 AUTHOR

Legend:
Removed from v.1  
changed lines
  Added in v.2

  ViewVC Help
Powered by ViewVC 1.1.26