-
-=back
-
-
-=head1 ACKNOWLEDGEMENTS
-
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Dobrica Pavlinusic, all rights reserved.
-
-This program is free software; you can redistribute it and/or modify it
-under the same terms as Perl itself.
-
-
-=cut
-
-1; # End of Redis
diff --git a/client-libraries/perl/lib/Redis/Hash.pm b/client-libraries/perl/lib/Redis/Hash.pm
deleted file mode 100644
index e5f8f7039..000000000
--- a/client-libraries/perl/lib/Redis/Hash.pm
+++ /dev/null
@@ -1,70 +0,0 @@
-package Redis::Hash;
-
-use strict;
-use warnings;
-
-use Tie::Hash;
-use base qw/Redis Tie::StdHash/;
-
-use Data::Dump qw/dump/;
-
-=head1 NAME
-
-Redis::Hash - tie perl hashes into Redis
-
-=head1 SYNOPSYS
-
- tie %name, 'Redis::Hash', 'prefix';
-
-=cut
-
-# mandatory methods
-sub TIEHASH {
- my ($class,$name) = @_;
- my $self = Redis->new;
- $name .= ':' if $name;
- $self->{name} = $name || '';
- bless $self => $class;
-}
-
-sub STORE {
- my ($self,$key,$value) = @_;
- $self->set( $self->{name} . $key, $value );
-}
-
-sub FETCH {
- my ($self,$key) = @_;
- $self->get( $self->{name} . $key );
-}
-
-sub FIRSTKEY {
- my $self = shift;
- $self->{keys} = [ $self->keys( $self->{name} . '*' ) ];
- $self->NEXTKEY;
-}
-
-sub NEXTKEY {
- my $self = shift;
- my $key = shift @{ $self->{keys} } || return;
- my $name = $self->{name};
- $key =~ s{^$name}{} || warn "can't strip $name from $key";
- return $key;
-}
-
-sub EXISTS {
- my ($self,$key) = @_;
- $self->exists( $self->{name} . $key );
-}
-
-sub DELETE {
- my ($self,$key) = @_;
- $self->del( $self->{name} . $key );
-}
-
-sub CLEAR {
- my ($self) = @_;
- $self->del( $_ ) foreach ( $self->keys( $self->{name} . '*' ) );
- $self->{keys} = [];
-}
-
-1;
diff --git a/client-libraries/perl/lib/Redis/List.pm b/client-libraries/perl/lib/Redis/List.pm
deleted file mode 100644
index 6bbc093ca..000000000
--- a/client-libraries/perl/lib/Redis/List.pm
+++ /dev/null
@@ -1,85 +0,0 @@
-package Redis::List;
-
-use strict;
-use warnings;
-
-use base qw/Redis Tie::Array/;
-
-=head1 NAME
-
-Redis::List - tie perl arrays into Redis lists
-
-=head1 SYNOPSYS
-
- tie @a, 'Redis::List', 'name';
-
-=cut
-
-# mandatory methods
-sub TIEARRAY {
- my ($class,$name) = @_;
- my $self = $class->new;
- $self->{name} = $name;
- bless $self => $class;
-}
-
-sub FETCH {
- my ($self,$index) = @_;
- $self->lindex( $self->{name}, $index );
-}
-
-sub FETCHSIZE {
- my ($self) = @_;
- $self->llen( $self->{name} );
-}
-
-sub STORE {
- my ($self,$index,$value) = @_;
- $self->lset( $self->{name}, $index, $value );
-}
-
-sub STORESIZE {
- my ($self,$count) = @_;
- $self->ltrim( $self->{name}, 0, $count );
-# if $count > $self->FETCHSIZE;
-}
-
-sub CLEAR {
- my ($self) = @_;
- $self->del( $self->{name} );
-}
-
-sub PUSH {
- my $self = shift;
- $self->rpush( $self->{name}, $_ ) foreach @_;
-}
-
-sub SHIFT {
- my $self = shift;
- $self->lpop( $self->{name} );
-}
-
-sub UNSHIFT {
- my $self = shift;
- $self->lpush( $self->{name}, $_ ) foreach @_;
-}
-
-sub SPLICE {
- my $self = shift;
- my $offset = shift;
- my $length = shift;
- $self->lrange( $self->{name}, $offset, $length );
- # FIXME rest of @_ ?
-}
-
-sub EXTEND {
- my ($self,$count) = @_;
- $self->rpush( $self->{name}, '' ) foreach ( $self->FETCHSIZE .. ( $count - 1 ) );
-}
-
-sub DESTROY {
- my $self = shift;
- $self->quit;
-}
-
-1;
diff --git a/client-libraries/perl/scripts/redis-benchmark.pl b/client-libraries/perl/scripts/redis-benchmark.pl
deleted file mode 100755
index 74759b06f..000000000
--- a/client-libraries/perl/scripts/redis-benchmark.pl
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/perl
-
-use warnings;
-use strict;
-use Benchmark qw/:all/;
-use lib 'lib';
-use Redis;
-
-my $r = Redis->new;
-
-my $i = 0;
-
-timethese( 100000, {
- '00_ping' => sub { $r->ping },
- '10_set' => sub { $r->set( 'foo', $i++ ) },
- '11_set_r' => sub { $r->set( 'bench-' . rand(), rand() ) },
- '20_get' => sub { $r->get( 'foo' ) },
- '21_get_r' => sub { $r->get( 'bench-' . rand() ) },
- '30_incr' => sub { $r->incr( 'counter' ) },
- '30_incr_r' => sub { $r->incr( 'bench-' . rand() ) },
- '40_lpush' => sub { $r->lpush( 'mylist', 'bar' ) },
- '40_lpush' => sub { $r->lpush( 'mylist', 'bar' ) },
- '50_lpop' => sub { $r->lpop( 'mylist' ) },
-});
diff --git a/client-libraries/perl/t/00-load.t b/client-libraries/perl/t/00-load.t
deleted file mode 100644
index d8a28cafa..000000000
--- a/client-libraries/perl/t/00-load.t
+++ /dev/null
@@ -1,9 +0,0 @@
-#!perl -T
-
-use Test::More tests => 1;
-
-BEGIN {
- use_ok( 'Redis' );
-}
-
-diag( "Testing Redis $Redis::VERSION, Perl $], $^X" );
diff --git a/client-libraries/perl/t/01-Redis.t b/client-libraries/perl/t/01-Redis.t
deleted file mode 100755
index 90247e93e..000000000
--- a/client-libraries/perl/t/01-Redis.t
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/bin/perl
-
-use warnings;
-use strict;
-
-use Test::More tests => 106;
-use Data::Dump qw/dump/;
-
-use lib 'lib';
-
-BEGIN {
- use_ok( 'Redis' );
-}
-
-ok( my $o = Redis->new(), 'new' );
-
-ok( $o->ping, 'ping' );
-
-
-diag "Commands operating on string values";
-
-ok( $o->set( foo => 'bar' ), 'set foo => bar' );
-
-ok( ! $o->setnx( foo => 'bar' ), 'setnx foo => bar fails' );
-
-cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );
-
-ok( $o->set( foo => 'baz' ), 'set foo => baz' );
-
-cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );
-
-ok( $o->set( 'test-undef' => 42 ), 'set test-undef' );
-ok( $o->set( 'test-undef' => undef ), 'set undef' );
-ok( ! defined $o->get( 'test-undef' ), 'get undef' );
-ok( $o->exists( 'test-undef' ), 'exists undef' );
-
-$o->del('non-existant');
-
-ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );
-ok( ! $o->get( 'non-existant' ), 'get non-existant' );
-
-ok( $o->set('key-next' => 0), 'key-next = 0' );
-
-my $key_next = 3;
-
-ok( $o->set('key-left' => $key_next), 'key-left' );
-
-is_deeply( [ $o->mget( 'foo', 'key-next', 'key-left' ) ], [ 'baz', 0, 3 ], 'mget' );
-
-my @keys;
-
-foreach my $id ( 0 .. $key_next ) {
- my $key = 'key-' . $id;
- push @keys, $key;
- ok( $o->set( $key => $id ), "set $key" );
- ok( $o->exists( $key ), "exists $key" );
- cmp_ok( $o->get( $key ), 'eq', $id, "get $key" );
- cmp_ok( $o->incr( 'key-next' ), '==', $id + 1, 'incr' );
- cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $id - 1, 'decr' );
-}
-
-cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
-
-ok( $o->set('test-incrby', 0), 'test-incrby' );
-ok( $o->set('test-decrby', 0), 'test-decry' );
-foreach ( 1 .. 3 ) {
- cmp_ok( $o->incrby('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
- cmp_ok( $o->decrby('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
-}
-
-ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' );
-ok( ! $o->del('non-existing' ), 'del non-existing' );
-
-cmp_ok( $o->type('foo'), 'eq', 'string', 'type' );
-
-cmp_ok( $o->keys('key-*'), '==', $key_next + 1, 'key-*' );
-is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' );
-
-ok( my $key = $o->randomkey, 'randomkey' );
-
-ok( $o->rename( 'test-incrby', 'test-renamed' ), 'rename' );
-ok( $o->exists( 'test-renamed' ), 'exists test-renamed' );
-
-eval { $o->rename( 'test-decrby', 'test-renamed', 1 ) };
-ok( $@, 'rename to existing key' );
-
-ok( my $nr_keys = $o->dbsize, 'dbsize' );
-
-
-diag "Commands operating on lists";
-
-my $list = 'test-list';
-
-$o->del($list) && diag "cleanup $list from last run";
-
-ok( $o->rpush( $list => "r$_" ), 'rpush' ) foreach ( 1 .. 3 );
-
-ok( $o->lpush( $list => "l$_" ), 'lpush' ) foreach ( 1 .. 2 );
-
-cmp_ok( $o->type($list), 'eq', 'list', 'type' );
-cmp_ok( $o->llen($list), '==', 5, 'llen' );
-
-is_deeply( [ $o->lrange( $list, 0, 1 ) ], [ 'l2', 'l1' ], 'lrange' );
-
-ok( $o->ltrim( $list, 1, 2 ), 'ltrim' );
-cmp_ok( $o->llen($list), '==', 2, 'llen after ltrim' );
-
-cmp_ok( $o->lindex( $list, 0 ), 'eq', 'l1', 'lindex' );
-cmp_ok( $o->lindex( $list, 1 ), 'eq', 'r1', 'lindex' );
-
-ok( $o->lset( $list, 0, 'foo' ), 'lset' );
-cmp_ok( $o->lindex( $list, 0 ), 'eq', 'foo', 'verified' );
-
-ok( $o->lrem( $list, 1, 'foo' ), 'lrem' );
-cmp_ok( $o->llen( $list ), '==', 1, 'llen after lrem' );
-
-cmp_ok( $o->lpop( $list ), 'eq', 'r1', 'lpop' );
-
-ok( ! $o->rpop( $list ), 'rpop' );
-
-
-diag "Commands operating on sets";
-
-my $set = 'test-set';
-$o->del($set);
-
-ok( $o->sadd( $set, 'foo' ), 'sadd' );
-ok( ! $o->sadd( $set, 'foo' ), 'sadd' );
-cmp_ok( $o->scard( $set ), '==', 1, 'scard' );
-ok( $o->sismember( $set, 'foo' ), 'sismember' );
-
-cmp_ok( $o->type( $set ), 'eq', 'set', 'type is set' );
-
-ok( $o->srem( $set, 'foo' ), 'srem' );
-ok( ! $o->srem( $set, 'foo' ), 'srem again' );
-cmp_ok( $o->scard( $set ), '==', 0, 'scard' );
-
-$o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' );
-$o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' );
-
-my $inter = [ 'baz', 'foo' ];
-
-is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' );
-
-ok( $o->sinterstore( 'test-set-inter', 'test-set1', 'test-set2' ), 'sinterstore' );
-
-cmp_ok( $o->scard( 'test-set-inter' ), '==', $#$inter + 1, 'cardinality of intersection' );
-
-
-diag "Multiple databases handling commands";
-
-ok( $o->select( 1 ), 'select' );
-ok( $o->select( 0 ), 'select' );
-
-ok( $o->move( 'foo', 1 ), 'move' );
-ok( ! $o->exists( 'foo' ), 'gone' );
-
-ok( $o->select( 1 ), 'select' );
-ok( $o->exists( 'foo' ), 'exists' );
-
-ok( $o->flushdb, 'flushdb' );
-cmp_ok( $o->dbsize, '==', 0, 'empty' );
-
-
-diag "Sorting";
-
-ok( $o->lpush( 'test-sort', $_ ), "put $_" ) foreach ( 1 .. 4 );
-cmp_ok( $o->llen( 'test-sort' ), '==', 4, 'llen' );
-
-is_deeply( [ $o->sort( 'test-sort' ) ], [ 1,2,3,4 ], 'sort' );
-is_deeply( [ $o->sort( 'test-sort DESC' ) ], [ 4,3,2,1 ], 'sort DESC' );
-
-
-diag "Persistence control commands";
-
-ok( $o->save, 'save' );
-ok( $o->bgsave, 'bgsave' );
-ok( $o->lastsave, 'lastsave' );
-#ok( $o->shutdown, 'shutdown' );
-diag "shutdown not tested";
-
-diag "Remote server control commands";
-
-ok( my $info = $o->info, 'info' );
-diag dump( $info );
-
-diag "Connection handling";
-
-ok( $o->quit, 'quit' );
diff --git a/client-libraries/perl/t/10-Redis-List.t b/client-libraries/perl/t/10-Redis-List.t
deleted file mode 100755
index 1ebdd757a..000000000
--- a/client-libraries/perl/t/10-Redis-List.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-use warnings;
-use strict;
-
-use Test::More tests => 8;
-use lib 'lib';
-use Data::Dump qw/dump/;
-
-BEGIN {
- use_ok( 'Redis::List' );
-}
-
-my @a;
-
-ok( my $o = tie( @a, 'Redis::List', 'test-redis-list' ), 'tie' );
-
-isa_ok( $o, 'Redis::List' );
-
-$o->CLEAR;
-
-ok( ! @a, 'empty list' );
-
-ok( @a = ( 'foo', 'bar', 'baz' ), '=' );
-is_deeply( [ @a ], [ 'foo', 'bar', 'baz' ] );
-
-ok( push( @a, 'push' ), 'push' );
-is_deeply( [ @a ], [ 'foo', 'bar', 'baz', 'push' ] );
-
-#diag dump( @a );
diff --git a/client-libraries/perl/t/20-Redis-Hash.t b/client-libraries/perl/t/20-Redis-Hash.t
deleted file mode 100755
index 7bd9dafcc..000000000
--- a/client-libraries/perl/t/20-Redis-Hash.t
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/perl
-
-use warnings;
-use strict;
-
-use Test::More tests => 7;
-use lib 'lib';
-use Data::Dump qw/dump/;
-
-BEGIN {
- use_ok( 'Redis::Hash' );
-}
-
-ok( my $o = tie( my %h, 'Redis::Hash', 'test-redis-hash' ), 'tie' );
-
-isa_ok( $o, 'Redis::Hash' );
-
-$o->CLEAR();
-
-ok( ! keys %h, 'empty' );
-
-ok( %h = ( 'foo' => 42, 'bar' => 1, 'baz' => 99 ), '=' );
-
-is_deeply( [ sort keys %h ], [ 'bar', 'baz', 'foo' ], 'keys' );
-
-is_deeply( \%h, { bar => 1, baz => 99, foo => 42, }, 'structure' );
-
-
-#diag dump( \%h );
-
diff --git a/client-libraries/perl/t/pod-coverage.t b/client-libraries/perl/t/pod-coverage.t
deleted file mode 100644
index fc40a57c2..000000000
--- a/client-libraries/perl/t/pod-coverage.t
+++ /dev/null
@@ -1,18 +0,0 @@
-use strict;
-use warnings;
-use Test::More;
-
-# Ensure a recent version of Test::Pod::Coverage
-my $min_tpc = 1.08;
-eval "use Test::Pod::Coverage $min_tpc";
-plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
- if $@;
-
-# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
-# but older versions don't recognize some common documentation styles
-my $min_pc = 0.18;
-eval "use Pod::Coverage $min_pc";
-plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
- if $@;
-
-all_pod_coverage_ok();
diff --git a/client-libraries/perl/t/pod.t b/client-libraries/perl/t/pod.t
deleted file mode 100644
index ee8b18ade..000000000
--- a/client-libraries/perl/t/pod.t
+++ /dev/null
@@ -1,12 +0,0 @@
-#!perl -T
-
-use strict;
-use warnings;
-use Test::More;
-
-# Ensure a recent version of Test::Pod
-my $min_tp = 1.22;
-eval "use Test::Pod $min_tp";
-plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
-
-all_pod_files_ok();
diff --git a/client-libraries/php/redis.php b/client-libraries/php/redis.php
deleted file mode 100644
index 6a0d21be6..000000000
--- a/client-libraries/php/redis.php
+++ /dev/null
@@ -1,374 +0,0 @@
-host = $host;
- $this->port = $port;
- }
-
- public function connect() {
- if ($this->_sock) return;
- if ($sock = fsockopen($this->host, $this->port, $errno, $errstr)) {
- $this->_sock = $sock;
- return;
- }
- $msg = "Cannot open socket to {$this->host}:{$this->port}";
- if ($errno || $errmsg)
- $msg .= "," . ($errno ? " error $errno" : "") .
- ($errmsg ? " $errmsg" : "");
- trigger_error("$msg.", E_USER_ERROR);
- }
-
- public function disconnect() {
- if ($this->_sock) @fclose($this->_sock);
- $this->_sock = null;
- }
-
- public function ping() {
- $this->connect();
- $this->write("PING\r\n");
- return $this->get_response();
- }
-
- public function do_echo($s) {
- $this->connect();
- $this->write("ECHO " . strlen($s) . "\r\n$s\r\n");
- return $this->get_response();
- }
-
- public function set($name, $value, $preserve=false) {
- $this->connect();
- $this->write(
- ($preserve ? 'SETNX' : 'SET') .
- " $name " . strlen($value) . "\r\n$value\r\n"
- );
- return $this->get_response();
- }
-
- public function get($name) {
- $this->connect();
- $this->write("GET $name\r\n");
- return $this->get_response();
- }
-
- public function mget($keys) {
- $this->connect();
- $this->write("MGET ".implode(" ",$keys)."\r\n");
- return $this->get_response();
- }
-
- public function incr($name, $amount=1) {
- $this->connect();
- if ($amount == 1)
- $this->write("INCR $name\r\n");
- else
- $this->write("INCRBY $name $amount\r\n");
- return $this->get_response();
- }
-
- public function decr($name, $amount=1) {
- $this->connect();
- if ($amount == 1)
- $this->write("DECR $name\r\n");
- else
- $this->write("DECRBY $name $amount\r\n");
- return $this->get_response();
- }
-
- public function exists($name) {
- $this->connect();
- $this->write("EXISTS $name\r\n");
- return $this->get_response();
- }
-
- public function delete($name) {
- $this->connect();
- $this->write("DEL $name\r\n");
- return $this->get_response();
- }
-
- public function keys($pattern) {
- $this->connect();
- $this->write("KEYS $pattern\r\n");
- return explode(' ', $this->get_response());
- }
-
- public function randomkey() {
- $this->connect();
- $this->write("RANDOMKEY\r\n");
- return $this->get_response();
- }
-
- public function rename($src, $dst) {
- $this->connect();
- $this->write("RENAME $src $dst\r\n");
- return $this->get_response();
- }
-
- public function renamenx($src, $dst) {
- $this->connect();
- $this->write("RENAMENX $src $dst\r\n");
- return $this->get_response();
- }
-
- public function expire($name, $time) {
- $this->connect();
- $this->write("EXPIRE $name $time\r\n");
- return $this->get_response();
- }
-
- public function push($name, $value, $tail=true) {
- // default is to append the element to the list
- $this->connect();
- $this->write(
- ($tail ? 'RPUSH' : 'LPUSH') .
- " $name " . strlen($value) . "\r\n$value\r\n"
- );
- return $this->get_response();
- }
-
- public function lpush($name, $value) {
- return $this->push($name, $value, false);
- }
-
- public function rpush($name, $value) {
- return $this->push($name, $value, true);
- }
-
- public function ltrim($name, $start, $end) {
- $this->connect();
- $this->write("LTRIM $name $start $end\r\n");
- return $this->get_response();
- }
-
- public function lindex($name, $index) {
- $this->connect();
- $this->write("LINDEX $name $index\r\n");
- return $this->get_response();
- }
-
- public function pop($name, $tail=true) {
- $this->connect();
- $this->write(
- ($tail ? 'RPOP' : 'LPOP') .
- " $name\r\n"
- );
- return $this->get_response();
- }
-
- public function lpop($name, $value) {
- return $this->pop($name, $value, false);
- }
-
- public function rpop($name, $value) {
- return $this->pop($name, $value, true);
- }
-
- public function llen($name) {
- $this->connect();
- $this->write("LLEN $name\r\n");
- return $this->get_response();
- }
-
- public function lrange($name, $start, $end) {
- $this->connect();
- $this->write("LRANGE $name $start $end\r\n");
- return $this->get_response();
- }
-
- public function sort($name, $query=false) {
- $this->connect();
- $this->write($query == false ? "SORT $name\r\n" : "SORT $name $query\r\n");
- return $this->get_response();
- }
-
- public function lset($name, $value, $index) {
- $this->connect();
- $this->write("LSET $name $index " . strlen($value) . "\r\n$value\r\n");
- return $this->get_response();
- }
-
- public function sadd($name, $value) {
- $this->connect();
- $this->write("SADD $name " . strlen($value) . "\r\n$value\r\n");
- return $this->get_response();
- }
-
- public function srem($name, $value) {
- $this->connect();
- $this->write("SREM $name " . strlen($value) . "\r\n$value\r\n");
- return $this->get_response();
- }
-
- public function sismember($name, $value) {
- $this->connect();
- $this->write("SISMEMBER $name " . strlen($value) . "\r\n$value\r\n");
- return $this->get_response();
- }
-
- public function sinter($sets) {
- $this->connect();
- $this->write('SINTER ' . implode(' ', $sets) . "\r\n");
- return $this->get_response();
- }
-
- public function smembers($name) {
- $this->connect();
- $this->write("SMEMBERS $name\r\n");
- return $this->get_response();
- }
-
- public function scard($name) {
- $this->connect();
- $this->write("SCARD $name\r\n");
- return $this->get_response();
- }
-
- public function select_db($name) {
- $this->connect();
- $this->write("SELECT $name\r\n");
- return $this->get_response();
- }
-
- public function move($name, $db) {
- $this->connect();
- $this->write("MOVE $name $db\r\n");
- return $this->get_response();
- }
-
- public function save($background=false) {
- $this->connect();
- $this->write(($background ? "BGSAVE\r\n" : "SAVE\r\n"));
- return $this->get_response();
- }
-
- public function bgsave($background=false) {
- return $this->save(true);
- }
-
- public function lastsave() {
- $this->connect();
- $this->write("LASTSAVE\r\n");
- return $this->get_response();
- }
-
- public function flushdb($all=false) {
- $this->connect();
- $this->write($all ? "FLUSHALL\r\n" : "FLUSHDB\r\n");
- return $this->get_response();
- }
-
- public function flushall() {
- return $this->flush(true);
- }
-
- public function info() {
- $this->connect();
- $this->write("INFO\r\n");
- $info = array();
- $data =& $this->get_response();
- foreach (explode("\r\n", $data) as $l) {
- if (!$l)
- continue;
- list($k, $v) = explode(':', $l, 2);
- $_v = strpos($v, '.') !== false ? (float)$v : (int)$v;
- $info[$k] = (string)$_v == $v ? $_v : $v;
- }
- return $info;
- }
-
- private function write($s) {
- while ($s) {
- $i = fwrite($this->_sock, $s);
- if ($i == 0) // || $i == strlen($s))
- break;
- $s = substr($s, $i);
- }
- }
-
- private function read($len=1024) {
- if ($s = fgets($this->_sock))
- return $s;
- $this->disconnect();
- trigger_error("Cannot read from socket.", E_USER_ERROR);
- }
-
- private function get_response() {
- $data = trim($this->read());
- $c = $data[0];
- $data = substr($data, 1);
- switch ($c) {
- case '-':
- trigger_error($data, E_USER_ERROR);
- break;
- case '+':
- return $data;
- case ':':
- $i = strpos($data, '.') !== false ? (int)$data : (float)$data;
- if ((string)$i != $data)
- trigger_error("Cannot convert data '$c$data' to integer", E_USER_ERROR);
- return $i;
- case '$':
- return $this->get_bulk_reply($c . $data);
- case '*':
- $num = (int)$data;
- if ((string)$num != $data)
- trigger_error("Cannot convert multi-response header '$data' to integer", E_USER_ERROR);
- $result = array();
- for ($i=0; $i<$num; $i++)
- $result[] =& $this->get_response();
- return $result;
- default:
- trigger_error("Invalid reply type byte: '$c'");
- }
- }
-
- private function get_bulk_reply($data=null) {
- if ($data === null)
- $data = trim($this->read());
- if ($data == '$-1')
- return null;
- $c = $data[0];
- $data = substr($data, 1);
- $bulklen = (int)$data;
- if ((string)$bulklen != $data)
- trigger_error("Cannot convert bulk read header '$c$data' to integer", E_USER_ERROR);
- if ($c != '$')
- trigger_error("Unkown response prefix for '$c$data'", E_USER_ERROR);
- $buffer = '';
- while ($bulklen) {
- $data = fread($this->_sock,$bulklen);
- $bulklen -= strlen($data);
- $buffer .= $data;
- }
- $crlf = fread($this->_sock,2);
- return $buffer;
- }
-}
-
-/*
-$r = new Redis();
-var_dump($r->set("foo","bar"));
-var_dump($r->get("foo"));
-var_dump($r->info());
-*/
-
-?>
diff --git a/client-libraries/php/tests.php b/client-libraries/php/tests.php
deleted file mode 100644
index d7bf74cfb..000000000
--- a/client-libraries/php/tests.php
+++ /dev/null
@@ -1,87 +0,0 @@
-connect();
-$r->select_db(9);
-$r->flushdb();
-echo "\n";
-echo $r->ping() . "\n";
-echo $r->do_echo('ECHO test') . "\n";
-echo "SET aaa " . $r->set('aaa', 'bbb') . "\n";
-echo "SETNX aaa " . $r->set('aaa', 'ccc', true) . "\n";
-echo "GET aaa " . $r->get('aaa') . "\n";
-echo "INCR aaa " . $r->incr('aaa') . "\n";
-echo "GET aaa " . $r->get('aaa') . "\n";
-echo "INCRBY aaa 3 " . $r->incr('aaa', 2) . "\n";
-echo "GET aaa " . $r->get('aaa') . "\n";
-echo "DECR aaa " . $r->decr('aaa') . "\n";
-echo "GET aaa " . $r->get('aaa') . "\n";
-echo "DECRBY aaa 2 " . $r->decr('aaa', 2) . "\n";
-echo "GET aaa " . $r->get('aaa') . "\n";
-echo "EXISTS aaa " . $r->exists('aaa') . "\n";
-echo "EXISTS fsfjslfjkls " . $r->exists('fsfjslfjkls') . "\n";
-echo "DELETE aaa " . $r->delete('aaa') . "\n";
-echo "EXISTS aaa " . $r->exists('aaa') . "\n";
-echo 'SET a1 a2 a3' . $r->set('a1', 'a') . $r->set('a2', 'b') . $r->set('a3', 'c') . "\n";
-echo 'KEYS a* ' . print_r($r->keys('a*'), true) . "\n";
-echo 'RANDOMKEY ' . $r->randomkey('a*') . "\n";
-echo 'RENAME a1 a0 ' . $r->rename('a1', 'a0') . "\n";
-echo 'RENAMENX a0 a2 ' . $r->renamenx('a0', 'a2') . "\n";
-echo 'RENAMENX a0 a1 ' . $r->renamenx('a0', 'a1') . "\n";
-
-echo 'LPUSH a0 aaa ' . $r->push('a0', 'aaa') . "\n";
-echo 'LPUSH a0 bbb ' . $r->push('a0', 'bbb') . "\n";
-echo 'RPUSH a0 ccc ' . $r->push('a0', 'ccc', false) . "\n";
-echo 'LLEN a0 ' . $r->llen('a0') . "\n";
-echo 'LRANGE sdkjhfskdjfh 0 100 ' . print_r($r->lrange('sdkjhfskdjfh', 0, 100), true) . "\n";
-echo 'LRANGE a0 0 0 ' . print_r($r->lrange('a0', 0, 0), true) . "\n";
-echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n";
-echo 'LTRIM a0 0 1 ' . $r->ltrim('a0', 0, 1) . "\n";
-echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n";
-echo 'LINDEX a0 0 ' . $r->lindex('a0', 0) . "\n";
-echo 'LPUSH a0 bbb ' . $r->push('a0', 'bbb') . "\n";
-echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n";
-echo 'RPOP a0 ' . $r->pop('a0') . "\n";
-echo 'LPOP a0 ' . $r->pop('a0', false) . "\n";
-echo 'LSET a0 ccc 0 ' . $r->lset('a0', 'ccc', 0) . "\n";
-echo 'LRANGE a0 0 100 ' . print_r($r->lrange('a0', 0, 100), true) . "\n";
-
-echo 'SADD s0 aaa ' . $r->sadd('s0', 'aaa') . "\n";
-echo 'SADD s0 aaa ' . $r->sadd('s0', 'aaa') . "\n";
-echo 'SADD s0 bbb ' . $r->sadd('s0', 'bbb') . "\n";
-echo 'SREM s0 bbb ' . $r->srem('s0', 'bbb') . "\n";
-echo 'SISMEMBER s0 aaa ' . $r->sismember('s0', 'aaa') . "\n";
-echo 'SISMEMBER s0 bbb ' . $r->sismember('s0', 'bbb') . "\n";
-echo 'SADD s0 bbb ' . $r->sadd('s0', 'bbb') . "\n";
-echo 'SADD s1 bbb ' . $r->sadd('s1', 'bbb') . "\n";
-echo 'SADD s1 aaa ' . $r->sadd('s1', 'aaa') . "\n";
-echo 'SINTER s0 s1 ' . print_r($r->sinter(array('s0', 's1')), true) . "\n";
-echo 'SREM s0 bbb ' . $r->srem('s0', 'bbb') . "\n";
-echo 'SINTER s0 s1 ' . print_r($r->sinter(array('s0', 's1')), true) . "\n";
-echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n";
-
-echo 'SELECT 8 ' . $r->select_db(8) . "\n";
-echo 'EXISTS s1 ' . $r->exists('s1') . "\n";
-if ($r->exists('s1'))
- echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n";
-echo 'SELECT 9 ' . $r->select_db(9) . "\n";
-echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n";
-echo 'MOVE s1 8 ' . $r->move('s1', 8) . "\n";
-echo 'EXISTS s1 ' . $r->exists('s1') . "\n";
-if ($r->exists('s1'))
- echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n";
-echo 'SELECT 8 ' . $r->select_db(8) . "\n";
-echo 'SMEMBERS s1 ' . print_r($r->smembers('s1'), true) . "\n";
-echo 'SELECT 9 ' . $r->select_db(9) . "\n";
-
-echo 'SAVE ' . $r->save() . "\n";
-echo 'BGSAVE ' . $r->save(true) . "\n";
-echo 'LASTSAVE ' . $r->lastsave() . "\n";
-
-echo 'INFO ' . print_r($r->info()) . "\n";
-echo "
\n";
-?>
diff --git a/client-libraries/python/redis.py b/client-libraries/python/redis.py
deleted file mode 100644
index 9618901ea..000000000
--- a/client-libraries/python/redis.py
+++ /dev/null
@@ -1,1051 +0,0 @@
-#!/usr/bin/env python
-
-""" redis.py - A client for the Redis daemon.
-
-History:
-
- - 20090603 fix missing errno import, add sunion and sunionstore commands,
- generalize shebang (Jochen Kupperschmidt)
-
-"""
-
-__author__ = "Ludovico Magnocavallo "
-__copyright__ = "Copyright 2009, Ludovico Magnocavallo"
-__license__ = "MIT"
-__version__ = "0.5"
-__revision__ = "$LastChangedRevision: 175 $"[22:-2]
-__date__ = "$LastChangedDate: 2009-03-17 16:15:55 +0100 (Mar, 17 Mar 2009) $"[18:-2]
-
-
-# TODO: Redis._get_multi_response
-
-
-import socket
-import decimal
-import errno
-
-
-BUFSIZE = 4096
-
-
-class RedisError(Exception): pass
-class ConnectionError(RedisError): pass
-class ResponseError(RedisError): pass
-class InvalidResponse(RedisError): pass
-class InvalidData(RedisError): pass
-
-
-class Redis(object):
- """The main Redis client.
- """
-
- def __init__(self, host=None, port=None, timeout=None, db=None, nodelay=None, charset='utf8', errors='strict'):
- self.host = host or 'localhost'
- self.port = port or 6379
- if timeout:
- socket.setdefaulttimeout(timeout)
- self.nodelay = nodelay
- self.charset = charset
- self.errors = errors
- self._sock = None
- self._fp = None
- self.db = db
-
- def _encode(self, s):
- if isinstance(s, str):
- return s
- if isinstance(s, unicode):
- try:
- return s.encode(self.charset, self.errors)
- except UnicodeEncodeError, e:
- raise InvalidData("Error encoding unicode value '%s': %s" % (value.encode(self.charset, 'replace'), e))
- return str(s)
-
- def _write(self, s):
- """
- >>> r = Redis(db=9)
- >>> r.connect()
- >>> r._sock.close()
- >>> try:
- ... r._write('pippo')
- ... except ConnectionError, e:
- ... print e
- Error 9 while writing to socket. Bad file descriptor.
- >>>
- >>>
- """
- try:
- self._sock.sendall(s)
- except socket.error, e:
- if e.args[0] == 32:
- # broken pipe
- self.disconnect()
- raise ConnectionError("Error %s while writing to socket. %s." % tuple(e.args))
-
- def _read(self):
- try:
- return self._fp.readline()
- except socket.error, e:
- if e.args and e.args[0] == errno.EAGAIN:
- return
- self.disconnect()
- raise ConnectionError("Error %s while reading from socket. %s." % tuple(e.args))
- if not data:
- self.disconnect()
- raise ConnectionError("Socket connection closed when reading.")
- return data
-
- def ping(self):
- """
- >>> r = Redis(db=9)
- >>> r.ping()
- 'PONG'
- >>>
- """
- self.connect()
- self._write('PING\r\n')
- return self.get_response()
-
- def set(self, name, value, preserve=False, getset=False):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'pippo')
- 'OK'
- >>> r.set('a', u'pippo \u3235')
- 'OK'
- >>> r.get('a')
- u'pippo \u3235'
- >>> r.set('b', 105.2)
- 'OK'
- >>> r.set('b', 'xxx', preserve=True)
- 0
- >>> r.get('b')
- Decimal("105.2")
- >>>
- """
- self.connect()
- # the following will raise an error for unicode values that can't be encoded to ascii
- # we could probably add an 'encoding' arg to init, but then what do we do with get()?
- # convert back to unicode? and what about ints, or pickled values?
- if getset: command = 'GETSET'
- elif preserve: command = 'SETNX'
- else: command = 'SET'
- value = self._encode(value)
- self._write('%s %s %s\r\n%s\r\n' % (
- command, name, len(value), value
- ))
- return self.get_response()
-
- def get(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'pippo'), r.set('b', 15), r.set('c', ' \\r\\naaa\\nbbb\\r\\ncccc\\nddd\\r\\n '), r.set('d', '\\r\\n')
- ('OK', 'OK', 'OK', 'OK')
- >>> r.get('a')
- u'pippo'
- >>> r.get('b')
- 15
- >>> r.get('d')
- u'\\r\\n'
- >>> r.get('b')
- 15
- >>> r.get('c')
- u' \\r\\naaa\\nbbb\\r\\ncccc\\nddd\\r\\n '
- >>> r.get('c')
- u' \\r\\naaa\\nbbb\\r\\ncccc\\nddd\\r\\n '
- >>> r.get('ajhsd')
- >>>
- """
- self.connect()
- self._write('GET %s\r\n' % name)
- return self.get_response()
-
- def getset(self, name, value):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'pippo')
- 'OK'
- >>> r.getset('a', 2)
- u'pippo'
- >>>
- """
- return self.set(name, value, getset=True)
-
- def mget(self, *args):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'pippo'), r.set('b', 15), r.set('c', '\\r\\naaa\\nbbb\\r\\ncccc\\nddd\\r\\n'), r.set('d', '\\r\\n')
- ('OK', 'OK', 'OK', 'OK')
- >>> r.mget('a', 'b', 'c', 'd')
- [u'pippo', 15, u'\\r\\naaa\\nbbb\\r\\ncccc\\nddd\\r\\n', u'\\r\\n']
- >>>
- """
- self.connect()
- self._write('MGET %s\r\n' % ' '.join(args))
- return self.get_response()
-
- def incr(self, name, amount=1):
- """
- >>> r = Redis(db=9)
- >>> r.delete('a')
- 1
- >>> r.incr('a')
- 1
- >>> r.incr('a')
- 2
- >>> r.incr('a', 2)
- 4
- >>>
- """
- self.connect()
- if amount == 1:
- self._write('INCR %s\r\n' % name)
- else:
- self._write('INCRBY %s %s\r\n' % (name, amount))
- return self.get_response()
-
- def decr(self, name, amount=1):
- """
- >>> r = Redis(db=9)
- >>> if r.get('a'):
- ... r.delete('a')
- ... else:
- ... print 1
- 1
- >>> r.decr('a')
- -1
- >>> r.decr('a')
- -2
- >>> r.decr('a', 5)
- -7
- >>>
- """
- self.connect()
- if amount == 1:
- self._write('DECR %s\r\n' % name)
- else:
- self._write('DECRBY %s %s\r\n' % (name, amount))
- return self.get_response()
-
- def exists(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.exists('dsjhfksjdhfkdsjfh')
- 0
- >>> r.set('a', 'a')
- 'OK'
- >>> r.exists('a')
- 1
- >>>
- """
- self.connect()
- self._write('EXISTS %s\r\n' % name)
- return self.get_response()
-
- def delete(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.delete('dsjhfksjdhfkdsjfh')
- 0
- >>> r.set('a', 'a')
- 'OK'
- >>> r.delete('a')
- 1
- >>> r.exists('a')
- 0
- >>> r.delete('a')
- 0
- >>>
- """
- self.connect()
- self._write('DEL %s\r\n' % name)
- return self.get_response()
-
- def get_type(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 3)
- 'OK'
- >>> r.get_type('a')
- 'string'
- >>> r.get_type('zzz')
- >>>
- """
- self.connect()
- self._write('TYPE %s\r\n' % name)
- res = self.get_response()
- return None if res == 'none' else res
-
- def keys(self, pattern):
- """
- >>> r = Redis(db=9)
- >>> r.flush()
- 'OK'
- >>> r.set('a', 'a')
- 'OK'
- >>> r.keys('a*')
- [u'a']
- >>> r.set('a2', 'a')
- 'OK'
- >>> r.keys('a*')
- [u'a', u'a2']
- >>> r.delete('a2')
- 1
- >>> r.keys('sjdfhskjh*')
- []
- >>>
- """
- self.connect()
- self._write('KEYS %s\r\n' % pattern)
- return self.get_response().split()
-
- def randomkey(self):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'a')
- 'OK'
- >>> isinstance(r.randomkey(), str)
- True
- >>>
- """
- #raise NotImplementedError("Implemented but buggy, do not use.")
- self.connect()
- self._write('RANDOMKEY\r\n')
- return self.get_response()
-
- def rename(self, src, dst, preserve=False):
- """
- >>> r = Redis(db=9)
- >>> try:
- ... r.rename('a', 'a')
- ... except ResponseError, e:
- ... print e
- source and destination objects are the same
- >>> r.rename('a', 'b')
- 'OK'
- >>> try:
- ... r.rename('a', 'b')
- ... except ResponseError, e:
- ... print e
- no such key
- >>> r.set('a', 1)
- 'OK'
- >>> r.rename('b', 'a', preserve=True)
- 0
- >>>
- """
- self.connect()
- if preserve:
- self._write('RENAMENX %s %s\r\n' % (src, dst))
- return self.get_response()
- else:
- self._write('RENAME %s %s\r\n' % (src, dst))
- return self.get_response() #.strip()
-
- def dbsize(self):
- """
- >>> r = Redis(db=9)
- >>> type(r.dbsize())
-
- >>>
- """
- self.connect()
- self._write('DBSIZE\r\n')
- return self.get_response()
-
- def ttl(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.ttl('a')
- -1
- >>> r.expire('a', 10)
- 1
- >>> r.ttl('a')
- 10
- >>> r.expire('a', 0)
- 0
- >>>
- """
- self.connect()
- self._write('TTL %s\r\n' % name)
- return self.get_response()
-
- def expire(self, name, time):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 1)
- 'OK'
- >>> r.expire('a', 1)
- 1
- >>> r.expire('zzzzz', 1)
- 0
- >>>
- """
- self.connect()
- self._write('EXPIRE %s %s\r\n' % (name, time))
- return self.get_response()
-
- def push(self, name, value, tail=False):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.push('l', 'a')
- 'OK'
- >>> r.set('a', 'a')
- 'OK'
- >>> try:
- ... r.push('a', 'a')
- ... except ResponseError, e:
- ... print e
- Operation against a key holding the wrong kind of value
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('%s %s %s\r\n%s\r\n' % (
- 'LPUSH' if tail else 'RPUSH', name, len(value), value
- ))
- return self.get_response()
-
- def llen(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.push('l', 'a')
- 'OK'
- >>> r.llen('l')
- 1
- >>> r.push('l', 'a')
- 'OK'
- >>> r.llen('l')
- 2
- >>>
- """
- self.connect()
- self._write('LLEN %s\r\n' % name)
- return self.get_response()
-
- def lrange(self, name, start, end):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.lrange('l', 0, 1)
- []
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.lrange('l', 0, 1)
- [u'aaa']
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.lrange('l', 0, 0)
- [u'aaa']
- >>> r.lrange('l', 0, 1)
- [u'aaa', u'bbb']
- >>> r.lrange('l', -1, 0)
- []
- >>> r.lrange('l', -1, -1)
- [u'bbb']
- >>>
- """
- self.connect()
- self._write('LRANGE %s %s %s\r\n' % (name, start, end))
- return self.get_response()
-
- def ltrim(self, name, start, end):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> try:
- ... r.ltrim('l', 0, 1)
- ... except ResponseError, e:
- ... print e
- no such key
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.push('l', 'ccc')
- 'OK'
- >>> r.ltrim('l', 0, 1)
- 'OK'
- >>> r.llen('l')
- 2
- >>> r.ltrim('l', 99, 95)
- 'OK'
- >>> r.llen('l')
- 0
- >>>
- """
- self.connect()
- self._write('LTRIM %s %s %s\r\n' % (name, start, end))
- return self.get_response()
-
- def lindex(self, name, index):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('l')
- >>> r.lindex('l', 0)
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.lindex('l', 0)
- u'aaa'
- >>> r.lindex('l', 2)
- >>> r.push('l', 'ccc')
- 'OK'
- >>> r.lindex('l', 1)
- u'ccc'
- >>> r.lindex('l', -1)
- u'ccc'
- >>>
- """
- self.connect()
- self._write('LINDEX %s %s\r\n' % (name, index))
- return self.get_response()
-
- def pop(self, name, tail=False):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.pop('l')
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.pop('l')
- u'aaa'
- >>> r.pop('l')
- u'bbb'
- >>> r.pop('l')
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.pop('l', tail=True)
- u'bbb'
- >>> r.pop('l')
- u'aaa'
- >>> r.pop('l')
- >>>
- """
- self.connect()
- self._write('%s %s\r\n' % ('RPOP' if tail else 'LPOP', name))
- return self.get_response()
-
- def lset(self, name, index, value):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> try:
- ... r.lset('l', 0, 'a')
- ... except ResponseError, e:
- ... print e
- no such key
- >>> r.push('l', 'aaa')
- 'OK'
- >>> try:
- ... r.lset('l', 1, 'a')
- ... except ResponseError, e:
- ... print e
- index out of range
- >>> r.lset('l', 0, 'bbb')
- 'OK'
- >>> r.lrange('l', 0, 1)
- [u'bbb']
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('LSET %s %s %s\r\n%s\r\n' % (
- name, index, len(value), value
- ))
- return self.get_response()
-
- def lrem(self, name, value, num=0):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.lrem('l', 'aaa')
- 2
- >>> r.lrange('l', 0, 10)
- [u'bbb']
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.lrem('l', 'aaa', 1)
- 1
- >>> r.lrem('l', 'aaa', 1)
- 1
- >>> r.lrem('l', 'aaa', 1)
- 0
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('LREM %s %s %s\r\n%s\r\n' % (
- name, num, len(value), value
- ))
- return self.get_response()
-
- def sort(self, name, by=None, get=None, start=None, num=None, desc=False, alpha=False):
- """
- >>> r = Redis(db=9)
- >>> r.delete('l')
- 1
- >>> r.push('l', 'ccc')
- 'OK'
- >>> r.push('l', 'aaa')
- 'OK'
- >>> r.push('l', 'ddd')
- 'OK'
- >>> r.push('l', 'bbb')
- 'OK'
- >>> r.sort('l', alpha=True)
- [u'aaa', u'bbb', u'ccc', u'ddd']
- >>> r.delete('l')
- 1
- >>> for i in range(1, 5):
- ... res = r.push('l', 1.0 / i)
- >>> r.sort('l')
- [Decimal("0.25"), Decimal("0.333333333333"), Decimal("0.5"), Decimal("1.0")]
- >>> r.sort('l', desc=True)
- [Decimal("1.0"), Decimal("0.5"), Decimal("0.333333333333"), Decimal("0.25")]
- >>> r.sort('l', desc=True, start=2, num=1)
- [Decimal("0.333333333333")]
- >>> r.set('weight_0.5', 10)
- 'OK'
- >>> r.sort('l', desc=True, by='weight_*')
- [Decimal("0.5"), Decimal("1.0"), Decimal("0.333333333333"), Decimal("0.25")]
- >>> for i in r.sort('l', desc=True):
- ... res = r.set('test_%s' % i, 100 - float(i))
- >>> r.sort('l', desc=True, get='test_*')
- [Decimal("99.0"), Decimal("99.5"), Decimal("99.6666666667"), Decimal("99.75")]
- >>> r.sort('l', desc=True, by='weight_*', get='test_*')
- [Decimal("99.5"), Decimal("99.0"), Decimal("99.6666666667"), Decimal("99.75")]
- >>> r.sort('l', desc=True, by='weight_*', get='missing_*')
- [None, None, None, None]
- >>>
- """
- stmt = ['SORT', name]
- if by:
- stmt.append("BY %s" % by)
- if start and num:
- stmt.append("LIMIT %s %s" % (start, num))
- if get is None:
- pass
- elif isinstance(get, basestring):
- stmt.append("GET %s" % get)
- elif isinstance(get, list) or isinstance(get, tuple):
- for g in get:
- stmt.append("GET %s" % g)
- else:
- raise RedisError("Invalid parameter 'get' for Redis sort")
- if desc:
- stmt.append("DESC")
- if alpha:
- stmt.append("ALPHA")
- self.connect()
- self._write(' '.join(stmt + ["\r\n"]))
- return self.get_response()
-
- def sadd(self, name, value):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('s')
- >>> r.sadd('s', 'a')
- 1
- >>> r.sadd('s', 'b')
- 1
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('SADD %s %s\r\n%s\r\n' % (
- name, len(value), value
- ))
- return self.get_response()
-
- def srem(self, name, value):
- """
- >>> r = Redis(db=9)
- >>> r.delete('s')
- 1
- >>> r.srem('s', 'aaa')
- 0
- >>> r.sadd('s', 'b')
- 1
- >>> r.srem('s', 'b')
- 1
- >>> r.sismember('s', 'b')
- 0
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('SREM %s %s\r\n%s\r\n' % (
- name, len(value), value
- ))
- return self.get_response()
-
- def sismember(self, name, value):
- """
- >>> r = Redis(db=9)
- >>> r.delete('s')
- 1
- >>> r.sismember('s', 'b')
- 0
- >>> r.sadd('s', 'a')
- 1
- >>> r.sismember('s', 'b')
- 0
- >>> r.sismember('s', 'a')
- 1
- >>>
- """
- self.connect()
- value = self._encode(value)
- self._write('SISMEMBER %s %s\r\n%s\r\n' % (
- name, len(value), value
- ))
- return self.get_response()
-
- def sinter(self, *args):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('s1')
- >>> res = r.delete('s2')
- >>> res = r.delete('s3')
- >>> r.sadd('s1', 'a')
- 1
- >>> r.sadd('s2', 'a')
- 1
- >>> r.sadd('s3', 'b')
- 1
- >>> try:
- ... r.sinter()
- ... except ResponseError, e:
- ... print e
- wrong number of arguments
- >>> try:
- ... r.sinter('l')
- ... except ResponseError, e:
- ... print e
- Operation against a key holding the wrong kind of value
- >>> r.sinter('s1', 's2', 's3')
- set([])
- >>> r.sinter('s1', 's2')
- set([u'a'])
- >>>
- """
- self.connect()
- self._write('SINTER %s\r\n' % ' '.join(args))
- return set(self.get_response())
-
- def sinterstore(self, dest, *args):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('s1')
- >>> res = r.delete('s2')
- >>> res = r.delete('s3')
- >>> r.sadd('s1', 'a')
- 1
- >>> r.sadd('s2', 'a')
- 1
- >>> r.sadd('s3', 'b')
- 1
- >>> r.sinterstore('s_s', 's1', 's2', 's3')
- 0
- >>> r.sinterstore('s_s', 's1', 's2')
- 1
- >>> r.smembers('s_s')
- set([u'a'])
- >>>
- """
- self.connect()
- self._write('SINTERSTORE %s %s\r\n' % (dest, ' '.join(args)))
- return self.get_response()
-
- def smembers(self, name):
- """
- >>> r = Redis(db=9)
- >>> r.delete('s')
- 1
- >>> r.sadd('s', 'a')
- 1
- >>> r.sadd('s', 'b')
- 1
- >>> try:
- ... r.smembers('l')
- ... except ResponseError, e:
- ... print e
- Operation against a key holding the wrong kind of value
- >>> r.smembers('s')
- set([u'a', u'b'])
- >>>
- """
- self.connect()
- self._write('SMEMBERS %s\r\n' % name)
- return set(self.get_response())
-
- def sunion(self, *args):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('s1')
- >>> res = r.delete('s2')
- >>> res = r.delete('s3')
- >>> r.sadd('s1', 'a')
- 1
- >>> r.sadd('s2', 'a')
- 1
- >>> r.sadd('s3', 'b')
- 1
- >>> r.sunion('s1', 's2', 's3')
- set([u'a', u'b'])
- >>> r.sadd('s2', 'c')
- 1
- >>> r.sunion('s1', 's2', 's3')
- set([u'a', u'c', u'b'])
- >>>
- """
- self.connect()
- self._write('SUNION %s\r\n' % ' '.join(args))
- return set(self.get_response())
-
- def sunionstore(self, dest, *args):
- """
- >>> r = Redis(db=9)
- >>> res = r.delete('s1')
- >>> res = r.delete('s2')
- >>> res = r.delete('s3')
- >>> r.sadd('s1', 'a')
- 1
- >>> r.sadd('s2', 'a')
- 1
- >>> r.sadd('s3', 'b')
- 1
- >>> r.sunionstore('s4', 's1', 's2', 's3')
- 2
- >>> r.smembers('s4')
- set([u'a', u'b'])
- >>>
- """
- self.connect()
- self._write('SUNIONSTORE %s %s\r\n' % (dest, ' '.join(args)))
- return self.get_response()
-
- def select(self, db):
- """
- >>> r = Redis(db=9)
- >>> r.delete('a')
- 1
- >>> r.select(10)
- 'OK'
- >>> r.set('a', 1)
- 'OK'
- >>> r.select(9)
- 'OK'
- >>> r.get('a')
- >>>
- """
- self.connect()
- self._write('SELECT %s\r\n' % db)
- return self.get_response()
-
- def move(self, name, db):
- """
- >>> r = Redis(db=9)
- >>> r.set('a', 'a')
- 'OK'
- >>> r.select(10)
- 'OK'
- >>> if r.get('a'):
- ... r.delete('a')
- ... else:
- ... print 1
- 1
- >>> r.select(9)
- 'OK'
- >>> r.move('a', 10)
- 1
- >>> r.get('a')
- >>> r.select(10)
- 'OK'
- >>> r.get('a')
- u'a'
- >>> r.select(9)
- 'OK'
- >>>
- """
- self.connect()
- self._write('MOVE %s %s\r\n' % (name, db))
- return self.get_response()
-
- def save(self, background=False):
- """
- >>> r = Redis(db=9)
- >>> r.save()
- 'OK'
- >>> try:
- ... resp = r.save(background=True)
- ... except ResponseError, e:
- ... assert str(e) == 'background save already in progress', str(e)
- ... else:
- ... assert resp == 'OK'
- >>>
- """
- self.connect()
- if background:
- self._write('BGSAVE\r\n')
- else:
- self._write('SAVE\r\n')
- return self.get_response()
-
- def lastsave(self):
- """
- >>> import time
- >>> r = Redis(db=9)
- >>> t = int(time.time())
- >>> r.save()
- 'OK'
- >>> r.lastsave() >= t
- True
- >>>
- """
- self.connect()
- self._write('LASTSAVE\r\n')
- return self.get_response()
-
- def flush(self, all_dbs=False):
- """
- >>> r = Redis(db=9)
- >>> r.flush()
- 'OK'
- >>> # r.flush(all_dbs=True)
- >>>
- """
- self.connect()
- self._write('%s\r\n' % ('FLUSHALL' if all_dbs else 'FLUSHDB'))
- return self.get_response()
-
- def info(self):
- """
- >>> r = Redis(db=9)
- >>> info = r.info()
- >>> info and isinstance(info, dict)
- True
- >>> isinstance(info.get('connected_clients'), int)
- True
- >>>
- """
- self.connect()
- self._write('INFO\r\n')
- info = dict()
- for l in self.get_response().split('\r\n'):
- if not l:
- continue
- k, v = l.split(':', 1)
- info[k] = int(v) if v.isdigit() else v
- return info
-
- def auth(self, passwd):
- self.connect()
- self._write('AUTH %s\r\n' % passwd)
- return self.get_response()
-
- def get_response(self):
- data = self._read().strip()
- if not data:
- self.disconnect()
- raise ConnectionError("Socket closed on remote end")
- c = data[0]
- if c == '-':
- raise ResponseError(data[5:] if data[:5] == '-ERR ' else data[1:])
- if c == '+':
- return data[1:]
- if c == '*':
- try:
- num = int(data[1:])
- except (TypeError, ValueError):
- raise InvalidResponse("Cannot convert multi-response header '%s' to integer" % data)
- result = list()
- for i in range(num):
- result.append(self._get_value())
- return result
- return self._get_value(data)
-
- def _get_value(self, data=None):
- data = data or self._read().strip()
- if data == '$-1':
- return None
- try:
- c, i = data[0], (int(data[1:]) if data.find('.') == -1 else float(data[1:]))
- except ValueError:
- raise InvalidResponse("Cannot convert data '%s' to integer" % data)
- if c == ':':
- return i
- if c != '$':
- raise InvalidResponse("Unkown response prefix for '%s'" % data)
- buf = []
- while True:
- data = self._read()
- i -= len(data)
- buf.append(data)
- if i < 0:
- break
- data = ''.join(buf)[:-2]
- try:
- return int(data) if data.find('.') == -1 else decimal.Decimal(data)
- except (ValueError, decimal.InvalidOperation):
- return data.decode(self.charset)
-
- def disconnect(self):
- if isinstance(self._sock, socket.socket):
- try:
- self._sock.close()
- except socket.error:
- pass
- self._sock = None
- self._fp = None
-
- def connect(self):
- """
- >>> r = Redis(db=9)
- >>> r.connect()
- >>> isinstance(r._sock, socket.socket)
- True
- >>> r.disconnect()
- >>>
- """
- if isinstance(self._sock, socket.socket):
- return
- try:
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.connect((self.host, self.port))
- except socket.error, e:
- raise ConnectionError("Error %s connecting to %s:%s. %s." % (e.args[0], self.host, self.port, e.args[1]))
- else:
- self._sock = sock
- self._fp = self._sock.makefile('r')
- if self.db:
- self.select(self.db)
- if self.nodelay is not None:
- self._sock.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, self.nodelay)
-
-
-if __name__ == '__main__':
- import doctest
- doctest.testmod()
-
diff --git a/client-libraries/ruby/.gitignore b/client-libraries/ruby/.gitignore
deleted file mode 100644
index f3b05636d..000000000
--- a/client-libraries/ruby/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-nohup.out
-redis/*
-rdsrv
-pkg/*
-coverage/*
-.idea
diff --git a/client-libraries/ruby/LICENSE b/client-libraries/ruby/LICENSE
deleted file mode 100644
index 5e648fa9d..000000000
--- a/client-libraries/ruby/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-Copyright (c) 2009 Ezra Zygmuntowicz
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/client-libraries/ruby/README.markdown b/client-libraries/ruby/README.markdown
deleted file mode 100644
index b36633d62..000000000
--- a/client-libraries/ruby/README.markdown
+++ /dev/null
@@ -1,34 +0,0 @@
-# redis-rb
-
-A ruby client library for the redis key value storage system.
-
-## Information about redis
-
-Redis is a key value store with some interesting features:
-1. It's fast.
-2. Keys are strings but values can have types of "NONE", "STRING", "LIST", or "SET". List's can be atomically push'd, pop'd, lpush'd, lpop'd and indexed. This allows you to store things like lists of comments under one key while retaining the ability to append comments without reading and putting back the whole list.
-
-See [redis on code.google.com](http://code.google.com/p/redis/wiki/README) for more information.
-
-## Dependencies
-
-1. rspec -
- sudo gem install rspec
-
-2. redis -
-
- rake redis:install
-
-2. dtach -
-
- rake dtach:install
-
-3. git - git is the new black.
-
-## Setup
-
-Use the tasks mentioned above (in Dependencies) to get your machine setup.
-
-## Examples
-
-Check the examples/ directory. *Note* you need to have redis-server running first.
\ No newline at end of file
diff --git a/client-libraries/ruby/Rakefile b/client-libraries/ruby/Rakefile
deleted file mode 100644
index e659d18ae..000000000
--- a/client-libraries/ruby/Rakefile
+++ /dev/null
@@ -1,62 +0,0 @@
-require 'rubygems'
-require 'rake/gempackagetask'
-require 'rubygems/specification'
-require 'date'
-require 'spec/rake/spectask'
-require 'tasks/redis.tasks'
-
-
-GEM = 'redis'
-GEM_NAME = 'redis'
-GEM_VERSION = '0.1'
-AUTHORS = ['Ezra Zygmuntowicz', 'Taylor Weibley', 'Matthew Clark', 'Brian McKinney', 'Salvatore Sanfilippo', 'Luca Guidi']
-EMAIL = "ez@engineyard.com"
-HOMEPAGE = "http://github.com/ezmobius/redis-rb"
-SUMMARY = "Ruby client library for redis key value storage server"
-
-spec = Gem::Specification.new do |s|
- s.name = GEM
- s.version = GEM_VERSION
- s.platform = Gem::Platform::RUBY
- s.has_rdoc = true
- s.extra_rdoc_files = ["LICENSE"]
- s.summary = SUMMARY
- s.description = s.summary
- s.authors = AUTHORS
- s.email = EMAIL
- s.homepage = HOMEPAGE
- s.add_dependency "rspec"
- s.require_path = 'lib'
- s.autorequire = GEM
- s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("{lib,tasks,spec}/**/*")
-end
-
-task :default => :spec
-
-desc "Run specs"
-Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.spec_opts = %w(-fs --color)
-end
-
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.gem_spec = spec
-end
-
-desc "install the gem locally"
-task :install => [:package] do
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
-end
-
-desc "create a gemspec file"
-task :make_spec do
- File.open("#{GEM}.gemspec", "w") do |file|
- file.puts spec.to_ruby
- end
-end
-
-desc "Run all examples with RCov"
-Spec::Rake::SpecTask.new(:rcov) do |t|
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.rcov = true
-end
diff --git a/client-libraries/ruby/bench.rb b/client-libraries/ruby/bench.rb
deleted file mode 100644
index 82898d0cb..000000000
--- a/client-libraries/ruby/bench.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-require 'benchmark'
-$:.push File.join(File.dirname(__FILE__), 'lib')
-require 'redis'
-
-times = 20000
-
-@r = Redis.new#(:debug => true)
-@r['foo'] = "The first line we sent to the server is some text"
-
-Benchmark.bmbm do |x|
- x.report("set") do
- 20000.times do |i|
- @r["set#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
- end
- end
-
- x.report("set (pipelined)") do
- @r.pipelined do |pipeline|
- 20000.times do |i|
- pipeline["set_pipelined#{i}"] = "The first line we sent to the server is some text"; @r["foo#{i}"]
- end
- end
- end
-
- x.report("push+trim") do
- 20000.times do |i|
- @r.push_head "push_trim#{i}", i
- @r.list_trim "push_trim#{i}", 0, 30
- end
- end
-
- x.report("push+trim (pipelined)") do
- @r.pipelined do |pipeline|
- 20000.times do |i|
- pipeline.push_head "push_trim_pipelined#{i}", i
- pipeline.list_trim "push_trim_pipelined#{i}", 0, 30
- end
- end
- end
-end
-
-@r.keys('*').each do |k|
- @r.delete k
-end
\ No newline at end of file
diff --git a/client-libraries/ruby/benchmarking/suite.rb b/client-libraries/ruby/benchmarking/suite.rb
deleted file mode 100644
index f03694b0e..000000000
--- a/client-libraries/ruby/benchmarking/suite.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-require 'fileutils'
-
-def run_in_background(command)
- fork { system command }
-end
-
-def with_all_segments(&block)
- 0.upto(9) do |segment_number|
- block_size = 100000
- start_index = segment_number * block_size
- end_index = start_index + block_size - 1
- block.call(start_index, end_index)
- end
-end
-
-#with_all_segments do |start_index, end_index|
-# puts "Initializing keys from #{start_index} to #{end_index}"
-# system "ruby worker.rb initialize #{start_index} #{end_index} 0"
-#end
-
-with_all_segments do |start_index, end_index|
- run_in_background "ruby worker.rb write #{start_index} #{end_index} 10"
- run_in_background "ruby worker.rb read #{start_index} #{end_index} 1"
-end
\ No newline at end of file
diff --git a/client-libraries/ruby/benchmarking/worker.rb b/client-libraries/ruby/benchmarking/worker.rb
deleted file mode 100644
index 836d03b06..000000000
--- a/client-libraries/ruby/benchmarking/worker.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-BENCHMARK_ROOT = File.dirname(__FILE__)
-REDIS_ROOT = File.join(BENCHMARK_ROOT, "..", "lib")
-
-$: << REDIS_ROOT
-require 'redis'
-require 'benchmark'
-
-def show_usage
- puts <<-EOL
- Usage: worker.rb [read:write]
- EOL
-end
-
-def shift_from_argv
- value = ARGV.shift
- unless value
- show_usage
- exit -1
- end
- value
-end
-
-operation = shift_from_argv.to_sym
-start_index = shift_from_argv.to_i
-end_index = shift_from_argv.to_i
-sleep_msec = shift_from_argv.to_i
-sleep_duration = sleep_msec/1000.0
-
-redis = Redis.new
-
-case operation
- when :initialize
-
- start_index.upto(end_index) do |i|
- redis[i] = 0
- end
-
- when :clear
-
- start_index.upto(end_index) do |i|
- redis.delete(i)
- end
-
- when :read, :write
-
- puts "Starting to #{operation} at segment #{end_index + 1}"
-
- loop do
- t1 = Time.now
- start_index.upto(end_index) do |i|
- case operation
- when :read
- redis.get(i)
- when :write
- redis.incr(i)
- else
- raise "Unknown operation: #{operation}"
- end
- sleep sleep_duration
- end
- t2 = Time.now
-
- requests_processed = end_index - start_index
- time = t2 - t1
- puts "#{t2.strftime("%H:%M")} [segment #{end_index + 1}] : Processed #{requests_processed} requests in #{time} seconds - #{(requests_processed/time).round} requests/sec"
- end
-
- else
- raise "Unknown operation: #{operation}"
-end
-
diff --git a/client-libraries/ruby/bin/distredis b/client-libraries/ruby/bin/distredis
deleted file mode 100755
index d5702079c..000000000
--- a/client-libraries/ruby/bin/distredis
+++ /dev/null
@@ -1,33 +0,0 @@
-require 'fileutils'
-
-class RedisCluster
-
- def initialize(opts={})
- opts = {:port => 6379, :host => 'localhost', :basedir => "#{Dir.pwd}/rdsrv" }.merge(opts)
- FileUtils.mkdir_p opts[:basedir]
- opts[:size].times do |i|
- port = opts[:port] + i
- FileUtils.mkdir_p "#{opts[:basedir]}/#{port}"
- File.open("#{opts[:basedir]}/#{port}.conf", 'w'){|f| f.write(make_config(port, "#{opts[:basedir]}/#{port}", "#{opts[:basedir]}/#{port}.log"))}
- system(%Q{#{File.join(File.expand_path(File.dirname(__FILE__)), "../redis/redis-server #{opts[:basedir]}/#{port}.conf &" )}})
- end
- end
-
- def make_config(port=6379, data=port, logfile='stdout', loglevel='debug')
- config = %Q{
-timeout 300
-save 900 1
-save 300 10
-save 60 10000
-dir #{data}
-loglevel #{loglevel}
-logfile #{logfile}
-databases 16
-port #{port}
- }
- end
-
-end
-
-
-RedisCluster.new :size => 4
\ No newline at end of file
diff --git a/client-libraries/ruby/examples/basic.rb b/client-libraries/ruby/examples/basic.rb
deleted file mode 100644
index 022796dbc..000000000
--- a/client-libraries/ruby/examples/basic.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'rubygems'
-require 'redis'
-
-r = Redis.new
-
-r.delete('foo')
-
-puts
-
-p'set foo to "bar"'
-r['foo'] = 'bar'
-
-puts
-
-p 'value of foo'
-p r['foo']
diff --git a/client-libraries/ruby/examples/incr-decr.rb b/client-libraries/ruby/examples/incr-decr.rb
deleted file mode 100644
index e951969a5..000000000
--- a/client-libraries/ruby/examples/incr-decr.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require 'rubygems'
-require 'redis'
-
-r = Redis.new
-
-puts
-p 'incr'
-r.delete 'counter'
-
-p r.incr('counter')
-p r.incr('counter')
-p r.incr('counter')
-
-puts
-p 'decr'
-p r.decr('counter')
-p r.decr('counter')
-p r.decr('counter')
diff --git a/client-libraries/ruby/examples/list.rb b/client-libraries/ruby/examples/list.rb
deleted file mode 100644
index 8f186c156..000000000
--- a/client-libraries/ruby/examples/list.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-require 'rubygems'
-require 'redis'
-
-r = Redis.new
-
-r.delete 'logs'
-
-puts
-
-p "pushing log messages into a LIST"
-r.push_tail 'logs', 'some log message'
-r.push_tail 'logs', 'another log message'
-r.push_tail 'logs', 'yet another log message'
-r.push_tail 'logs', 'also another log message'
-
-puts
-p 'contents of logs LIST'
-
-p r.list_range('logs', 0, -1)
-
-puts
-p 'Trim logs LIST to last 2 elements(easy circular buffer)'
-
-r.list_trim('logs', -2, -1)
-
-p r.list_range('logs', 0, -1)
diff --git a/client-libraries/ruby/examples/sets.rb b/client-libraries/ruby/examples/sets.rb
deleted file mode 100644
index 1ba4e30c8..000000000
--- a/client-libraries/ruby/examples/sets.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-require 'rubygems'
-require 'redis'
-
-r = Redis.new
-
-r.delete 'foo-tags'
-r.delete 'bar-tags'
-
-puts
-p "create a set of tags on foo-tags"
-
-r.set_add 'foo-tags', 'one'
-r.set_add 'foo-tags', 'two'
-r.set_add 'foo-tags', 'three'
-
-puts
-p "create a set of tags on bar-tags"
-
-r.set_add 'bar-tags', 'three'
-r.set_add 'bar-tags', 'four'
-r.set_add 'bar-tags', 'five'
-
-puts
-p 'foo-tags'
-
-p r.set_members('foo-tags')
-
-puts
-p 'bar-tags'
-
-p r.set_members('bar-tags')
-
-puts
-p 'intersection of foo-tags and bar-tags'
-
-p r.set_intersect('foo-tags', 'bar-tags')
diff --git a/client-libraries/ruby/lib/dist_redis.rb b/client-libraries/ruby/lib/dist_redis.rb
deleted file mode 100644
index d92c956ef..000000000
--- a/client-libraries/ruby/lib/dist_redis.rb
+++ /dev/null
@@ -1,124 +0,0 @@
-require 'redis'
-require 'hash_ring'
-class DistRedis
- attr_reader :ring
- def initialize(opts={})
- hosts = []
-
- db = opts[:db] || nil
- timeout = opts[:timeout] || nil
-
- raise Error, "No hosts given" unless opts[:hosts]
-
- opts[:hosts].each do |h|
- host, port = h.split(':')
- hosts << Redis.new(:host => host, :port => port, :db => db, :timeout => timeout)
- end
-
- @ring = HashRing.new hosts
- end
-
- def node_for_key(key)
- key = $1 if key =~ /\{(.*)?\}/
- @ring.get_node(key)
- end
-
- def add_server(server)
- server, port = server.split(':')
- @ring.add_node Redis.new(:host => server, :port => port)
- end
-
- def method_missing(sym, *args, &blk)
- if redis = node_for_key(args.first.to_s)
- redis.send sym, *args, &blk
- else
- super
- end
- end
-
- def keys(glob)
- @ring.nodes.map do |red|
- red.keys(glob)
- end
- end
-
- def save
- on_each_node :save
- end
-
- def bgsave
- on_each_node :bgsave
- end
-
- def quit
- on_each_node :quit
- end
-
- def flush_all
- on_each_node :flush_all
- end
- alias_method :flushall, :flush_all
-
- def flush_db
- on_each_node :flush_db
- end
- alias_method :flushdb, :flush_db
-
- def delete_cloud!
- @ring.nodes.each do |red|
- red.keys("*").each do |key|
- red.delete key
- end
- end
- end
-
- def on_each_node(command, *args)
- @ring.nodes.each do |red|
- red.send(command, *args)
- end
- end
-
-end
-
-
-if __FILE__ == $0
-
-r = DistRedis.new 'localhost:6379', 'localhost:6380', 'localhost:6381', 'localhost:6382'
- r['urmom'] = 'urmom'
- r['urdad'] = 'urdad'
- r['urmom1'] = 'urmom1'
- r['urdad1'] = 'urdad1'
- r['urmom2'] = 'urmom2'
- r['urdad2'] = 'urdad2'
- r['urmom3'] = 'urmom3'
- r['urdad3'] = 'urdad3'
- p r['urmom']
- p r['urdad']
- p r['urmom1']
- p r['urdad1']
- p r['urmom2']
- p r['urdad2']
- p r['urmom3']
- p r['urdad3']
-
- r.push_tail 'listor', 'foo1'
- r.push_tail 'listor', 'foo2'
- r.push_tail 'listor', 'foo3'
- r.push_tail 'listor', 'foo4'
- r.push_tail 'listor', 'foo5'
-
- p r.pop_tail('listor')
- p r.pop_tail('listor')
- p r.pop_tail('listor')
- p r.pop_tail('listor')
- p r.pop_tail('listor')
-
- puts "key distribution:"
-
- r.ring.nodes.each do |red|
- p [red.port, red.keys("*")]
- end
- r.delete_cloud!
- p r.keys('*')
-
-end
diff --git a/client-libraries/ruby/lib/hash_ring.rb b/client-libraries/ruby/lib/hash_ring.rb
deleted file mode 100644
index ec4886361..000000000
--- a/client-libraries/ruby/lib/hash_ring.rb
+++ /dev/null
@@ -1,128 +0,0 @@
-require 'zlib'
-
-class HashRing
-
- POINTS_PER_SERVER = 160 # this is the default in libmemcached
-
- attr_reader :ring, :sorted_keys, :replicas, :nodes
-
- # nodes is a list of objects that have a proper to_s representation.
- # replicas indicates how many virtual points should be used pr. node,
- # replicas are required to improve the distribution.
- def initialize(nodes=[], replicas=POINTS_PER_SERVER)
- @replicas = replicas
- @ring = {}
- @nodes = []
- @sorted_keys = []
- nodes.each do |node|
- add_node(node)
- end
- end
-
- # Adds a `node` to the hash ring (including a number of replicas).
- def add_node(node)
- @nodes << node
- @replicas.times do |i|
- key = Zlib.crc32("#{node}:#{i}")
- @ring[key] = node
- @sorted_keys << key
- end
- @sorted_keys.sort!
- end
-
- def remove_node(node)
- @nodes.reject!{|n| n.to_s == node.to_s}
- @replicas.times do |i|
- key = Zlib.crc32("#{node}:#{i}")
- @ring.delete(key)
- @sorted_keys.reject! {|k| k == key}
- end
- end
-
- # get the node in the hash ring for this key
- def get_node(key)
- get_node_pos(key)[0]
- end
-
- def get_node_pos(key)
- return [nil,nil] if @ring.size == 0
- crc = Zlib.crc32(key)
- idx = HashRing.binary_search(@sorted_keys, crc)
- return [@ring[@sorted_keys[idx]], idx]
- end
-
- def iter_nodes(key)
- return [nil,nil] if @ring.size == 0
- node, pos = get_node_pos(key)
- @sorted_keys[pos..-1].each do |k|
- yield @ring[k]
- end
- end
-
- class << self
-
- # gem install RubyInline to use this code
- # Native extension to perform the binary search within the hashring.
- # There's a pure ruby version below so this is purely optional
- # for performance. In testing 20k gets and sets, the native
- # binary search shaved about 12% off the runtime (9sec -> 8sec).
- begin
- require 'inline'
- inline do |builder|
- builder.c <<-EOM
- int binary_search(VALUE ary, unsigned int r) {
- int upper = RARRAY_LEN(ary) - 1;
- int lower = 0;
- int idx = 0;
-
- while (lower <= upper) {
- idx = (lower + upper) / 2;
-
- VALUE continuumValue = RARRAY_PTR(ary)[idx];
- unsigned int l = NUM2UINT(continuumValue);
- if (l == r) {
- return idx;
- }
- else if (l > r) {
- upper = idx - 1;
- }
- else {
- lower = idx + 1;
- }
- }
- return upper;
- }
- EOM
- end
- rescue Exception => e
- # Find the closest index in HashRing with value <= the given value
- def binary_search(ary, value, &block)
- upper = ary.size - 1
- lower = 0
- idx = 0
-
- while(lower <= upper) do
- idx = (lower + upper) / 2
- comp = ary[idx] <=> value
-
- if comp == 0
- return idx
- elsif comp > 0
- upper = idx - 1
- else
- lower = idx + 1
- end
- end
- return upper
- end
-
- end
- end
-
-end
-
-# ring = HashRing.new ['server1', 'server2', 'server3']
-# p ring
-# #
-# p ring.get_node "kjhjkjlkjlkkh"
-#
\ No newline at end of file
diff --git a/client-libraries/ruby/lib/pipeline.rb b/client-libraries/ruby/lib/pipeline.rb
deleted file mode 100644
index acab5acc5..000000000
--- a/client-libraries/ruby/lib/pipeline.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require "redis"
-
-class Redis
- class Pipeline < Redis
- BUFFER_SIZE = 50_000
-
- def initialize(redis)
- @redis = redis
- @commands = []
- end
-
- def call_command(command)
- @commands << command
- end
-
- def execute
- @redis.call_command(@commands)
- @commands.clear
- end
-
- end
-end
diff --git a/client-libraries/ruby/lib/redis.rb b/client-libraries/ruby/lib/redis.rb
deleted file mode 100644
index bbe5343ef..000000000
--- a/client-libraries/ruby/lib/redis.rb
+++ /dev/null
@@ -1,316 +0,0 @@
-require 'socket'
-require File.join(File.dirname(__FILE__),'pipeline')
-
-begin
- if RUBY_VERSION >= '1.9'
- require 'timeout'
- RedisTimer = Timeout
- else
- require 'system_timer'
- RedisTimer = SystemTimer
- end
-rescue LoadError
- RedisTimer = nil
-end
-
-class Redis
- OK = "OK".freeze
- MINUS = "-".freeze
- PLUS = "+".freeze
- COLON = ":".freeze
- DOLLAR = "$".freeze
- ASTERISK = "*".freeze
-
- BULK_COMMANDS = {
- "set" => true,
- "setnx" => true,
- "rpush" => true,
- "lpush" => true,
- "lset" => true,
- "lrem" => true,
- "sadd" => true,
- "srem" => true,
- "sismember" => true,
- "echo" => true,
- "getset" => true,
- "smove" => true
- }
-
- BOOLEAN_PROCESSOR = lambda{|r| r == 1 }
-
- REPLY_PROCESSOR = {
- "exists" => BOOLEAN_PROCESSOR,
- "sismember" => BOOLEAN_PROCESSOR,
- "sadd" => BOOLEAN_PROCESSOR,
- "srem" => BOOLEAN_PROCESSOR,
- "smove" => BOOLEAN_PROCESSOR,
- "move" => BOOLEAN_PROCESSOR,
- "setnx" => BOOLEAN_PROCESSOR,
- "del" => BOOLEAN_PROCESSOR,
- "renamenx" => BOOLEAN_PROCESSOR,
- "expire" => BOOLEAN_PROCESSOR,
- "keys" => lambda{|r| r.split(" ")},
- "info" => lambda{|r|
- info = {}
- r.each_line {|kv|
- k,v = kv.split(":",2).map{|x| x.chomp}
- info[k.to_sym] = v
- }
- info
- }
- }
-
- ALIASES = {
- "flush_db" => "flushdb",
- "flush_all" => "flushall",
- "last_save" => "lastsave",
- "key?" => "exists",
- "delete" => "del",
- "randkey" => "randomkey",
- "list_length" => "llen",
- "push_tail" => "rpush",
- "push_head" => "lpush",
- "pop_tail" => "rpop",
- "pop_head" => "lpop",
- "list_set" => "lset",
- "list_range" => "lrange",
- "list_trim" => "ltrim",
- "list_index" => "lindex",
- "list_rm" => "lrem",
- "set_add" => "sadd",
- "set_delete" => "srem",
- "set_count" => "scard",
- "set_member?" => "sismember",
- "set_members" => "smembers",
- "set_intersect" => "sinter",
- "set_intersect_store" => "sinterstore",
- "set_inter_store" => "sinterstore",
- "set_union" => "sunion",
- "set_union_store" => "sunionstore",
- "set_diff" => "sdiff",
- "set_diff_store" => "sdiffstore",
- "set_move" => "smove",
- "set_unless_exists" => "setnx",
- "rename_unless_exists" => "renamenx",
- "type?" => "type"
- }
-
- DISABLED_COMMANDS = {
- "monitor" => true,
- "sync" => true
- }
-
- def initialize(options = {})
- @host = options[:host] || '127.0.0.1'
- @port = (options[:port] || 6379).to_i
- @db = (options[:db] || 0).to_i
- @timeout = (options[:timeout] || 5).to_i
- @password = options[:password]
- @logger = options[:logger]
-
- @logger.info { self.to_s } if @logger
- connect_to_server
- end
-
- def to_s
- "Redis Client connected to #{server} against DB #{@db}"
- end
-
- def server
- "#{@host}:#{@port}"
- end
-
- def connect_to_server
- @sock = connect_to(@host, @port, @timeout == 0 ? nil : @timeout)
- call_command(["auth",@password]) if @password
- call_command(["select",@db]) unless @db == 0
- end
-
- def connect_to(host, port, timeout=nil)
- # We support connect() timeout only if system_timer is availabe
- # or if we are running against Ruby >= 1.9
- # Timeout reading from the socket instead will be supported anyway.
- if @timeout != 0 and RedisTimer
- begin
- sock = TCPSocket.new(host, port)
- rescue Timeout::Error
- @sock = nil
- raise Timeout::Error, "Timeout connecting to the server"
- end
- else
- sock = TCPSocket.new(host, port)
- end
- sock.setsockopt Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1
-
- # If the timeout is set we set the low level socket options in order
- # to make sure a blocking read will return after the specified number
- # of seconds. This hack is from memcached ruby client.
- if timeout
- secs = Integer(timeout)
- usecs = Integer((timeout - secs) * 1_000_000)
- optval = [secs, usecs].pack("l_2")
- sock.setsockopt Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, optval
- sock.setsockopt Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, optval
- end
- sock
- end
-
- def method_missing(*argv)
- call_command(argv)
- end
-
- def call_command(argv)
- @logger.debug { argv.inspect } if @logger
-
- # this wrapper to raw_call_command handle reconnection on socket
- # error. We try to reconnect just one time, otherwise let the error
- # araise.
- connect_to_server if !@sock
-
- begin
- raw_call_command(argv.dup)
- rescue Errno::ECONNRESET, Errno::EPIPE
- @sock.close
- @sock = nil
- connect_to_server
- raw_call_command(argv.dup)
- end
- end
-
- def raw_call_command(argvp)
- pipeline = argvp[0].is_a?(Array)
-
- unless pipeline
- argvv = [argvp]
- else
- argvv = argvp
- end
-
- command = ''
-
- argvv.each do |argv|
- bulk = nil
- argv[0] = argv[0].to_s.downcase
- argv[0] = ALIASES[argv[0]] if ALIASES[argv[0]]
- raise "#{argv[0]} command is disabled" if DISABLED_COMMANDS[argv[0]]
- if BULK_COMMANDS[argv[0]] and argv.length > 1
- bulk = argv[-1].to_s
- argv[-1] = bulk.respond_to?(:bytesize) ? bulk.bytesize : bulk.size
- end
- command << "#{argv.join(' ')}\r\n"
- command << "#{bulk}\r\n" if bulk
- end
-
- @sock.write(command)
-
- results = argvv.map do |argv|
- processor = REPLY_PROCESSOR[argv[0]]
- processor ? processor.call(read_reply) : read_reply
- end
-
- return pipeline ? results : results[0]
- end
-
- def select(*args)
- raise "SELECT not allowed, use the :db option when creating the object"
- end
-
- def [](key)
- self.get(key)
- end
-
- def []=(key,value)
- set(key,value)
- end
-
- def set(key, value, expiry=nil)
- s = call_command([:set, key, value]) == OK
- expire(key, expiry) if s && expiry
- s
- end
-
- def sort(key, options = {})
- cmd = ["SORT"]
- cmd << key
- cmd << "BY #{options[:by]}" if options[:by]
- cmd << "GET #{[options[:get]].flatten * ' GET '}" if options[:get]
- cmd << "#{options[:order]}" if options[:order]
- cmd << "LIMIT #{options[:limit].join(' ')}" if options[:limit]
- call_command(cmd)
- end
-
- def incr(key, increment = nil)
- call_command(increment ? ["incrby",key,increment] : ["incr",key])
- end
-
- def decr(key,decrement = nil)
- call_command(decrement ? ["decrby",key,decrement] : ["decr",key])
- end
-
- # Similar to memcache.rb's #get_multi, returns a hash mapping
- # keys to values.
- def mapped_mget(*keys)
- mget(*keys).inject({}) do |hash, value|
- key = keys.shift
- value.nil? ? hash : hash.merge(key => value)
- end
- end
-
- # Ruby defines a now deprecated type method so we need to override it here
- # since it will never hit method_missing
- def type(key)
- call_command(['type', key])
- end
-
- def quit
- call_command(['quit'])
- rescue Errno::ECONNRESET
- end
-
- def pipelined(&block)
- pipeline = Pipeline.new self
- yield pipeline
- pipeline.execute
- end
-
- def read_reply
- # We read the first byte using read() mainly because gets() is
- # immune to raw socket timeouts.
- begin
- rtype = @sock.read(1)
- rescue Errno::EAGAIN
- # We want to make sure it reconnects on the next command after the
- # timeout. Otherwise the server may reply in the meantime leaving
- # the protocol in a desync status.
- @sock = nil
- raise Errno::EAGAIN, "Timeout reading from the socket"
- end
-
- raise Errno::ECONNRESET,"Connection lost" if !rtype
- line = @sock.gets
- case rtype
- when MINUS
- raise MINUS + line.strip
- when PLUS
- line.strip
- when COLON
- line.to_i
- when DOLLAR
- bulklen = line.to_i
- return nil if bulklen == -1
- data = @sock.read(bulklen)
- @sock.read(2) # CRLF
- data
- when ASTERISK
- objects = line.to_i
- return nil if bulklen == -1
- res = []
- objects.times {
- res << read_reply
- }
- res
- else
- raise "Protocol error, got '#{rtype}' as initial reply byte"
- end
- end
-end
diff --git a/client-libraries/ruby/profile.rb b/client-libraries/ruby/profile.rb
deleted file mode 100644
index e5dc8c03a..000000000
--- a/client-libraries/ruby/profile.rb
+++ /dev/null
@@ -1,22 +0,0 @@
-require 'rubygems'
-require 'ruby-prof'
-require "#{File.dirname(__FILE__)}/lib/redis"
-
-
-mode = ARGV.shift || 'process_time'
-n = (ARGV.shift || 200).to_i
-
-r = Redis.new
-RubyProf.measure_mode = RubyProf.const_get(mode.upcase)
-RubyProf.start
-
-n.times do |i|
- key = "foo#{i}"
- r[key] = key * 10
- r[key]
-end
-
-results = RubyProf.stop
-File.open("profile.#{mode}", 'w') do |out|
- RubyProf::CallTreePrinter.new(results).print(out)
-end
diff --git a/client-libraries/ruby/redis-rb.gemspec b/client-libraries/ruby/redis-rb.gemspec
deleted file mode 100644
index 04de472c1..000000000
--- a/client-libraries/ruby/redis-rb.gemspec
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{redis}
- s.version = "0.1"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Ezra Zygmuntowicz", "Taylor Weibley", "Matthew Clark", "Brian McKinney", "Salvatore Sanfilippo", "Luca Guidi"]
- # s.autorequire = %q{redis-rb}
- s.date = %q{2009-06-23}
- s.description = %q{Ruby client library for redis key value storage server}
- s.email = %q{ez@engineyard.com}
- s.extra_rdoc_files = ["LICENSE"]
- s.files = ["LICENSE", "README.markdown", "Rakefile", "lib/dist_redis.rb", "lib/hash_ring.rb", "lib/pipeline.rb", "lib/redis.rb", "spec/redis_spec.rb", "spec/spec_helper.rb"]
- s.has_rdoc = true
- s.homepage = %q{http://github.com/ezmobius/redis-rb}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.1}
- s.summary = %q{Ruby client library for redis key value storage server}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- else
- end
- else
- end
-end
diff --git a/client-libraries/ruby/spec/redis_spec.rb b/client-libraries/ruby/spec/redis_spec.rb
deleted file mode 100644
index 0da249e11..000000000
--- a/client-libraries/ruby/spec/redis_spec.rb
+++ /dev/null
@@ -1,478 +0,0 @@
-require File.dirname(__FILE__) + '/spec_helper'
-require 'logger'
-
-class Foo
- attr_accessor :bar
- def initialize(bar)
- @bar = bar
- end
-
- def ==(other)
- @bar == other.bar
- end
-end
-
-describe "redis" do
- before(:all) do
- # use database 15 for testing so we dont accidentally step on you real data
- @r = Redis.new :db => 15
- end
-
- before(:each) do
- @r['foo'] = 'bar'
- end
-
- after(:each) do
- @r.keys('*').each {|k| @r.del k}
- end
-
- after(:all) do
- @r.quit
- end
-
- it "should be able connect without a timeout" do
- lambda { Redis.new :timeout => 0 }.should_not raise_error
- end
-
- it "should be able to provide a logger" do
- log = StringIO.new
- r = Redis.new :db => 15, :logger => Logger.new(log)
- r.ping
- log.string.should include("ping")
- end
-
- it "should be able to PING" do
- @r.ping.should == 'PONG'
- end
-
- it "should be able to GET a key" do
- @r['foo'].should == 'bar'
- end
-
- it "should be able to SET a key" do
- @r['foo'] = 'nik'
- @r['foo'].should == 'nik'
- end
-
- it "should properly handle trailing newline characters" do
- @r['foo'] = "bar\n"
- @r['foo'].should == "bar\n"
- end
-
- it "should store and retrieve all possible characters at the beginning and the end of a string" do
- (0..255).each do |char_idx|
- string = "#{char_idx.chr}---#{char_idx.chr}"
- @r['foo'] = string
- @r['foo'].should == string
- end
- end
-
- it "should be able to SET a key with an expiry" do
- @r.set('foo', 'bar', 1)
- @r['foo'].should == 'bar'
- sleep 2
- @r['foo'].should == nil
- end
-
- it "should be able to return a TTL for a key" do
- @r.set('foo', 'bar', 1)
- @r.ttl('foo').should == 1
- end
-
- it "should be able to SETNX" do
- @r['foo'] = 'nik'
- @r['foo'].should == 'nik'
- @r.setnx 'foo', 'bar'
- @r['foo'].should == 'nik'
- end
- #
- it "should be able to GETSET" do
- @r.getset('foo', 'baz').should == 'bar'
- @r['foo'].should == 'baz'
- end
- #
- it "should be able to INCR a key" do
- @r.del('counter')
- @r.incr('counter').should == 1
- @r.incr('counter').should == 2
- @r.incr('counter').should == 3
- end
- #
- it "should be able to INCRBY a key" do
- @r.del('counter')
- @r.incrby('counter', 1).should == 1
- @r.incrby('counter', 2).should == 3
- @r.incrby('counter', 3).should == 6
- end
- #
- it "should be able to DECR a key" do
- @r.del('counter')
- @r.incr('counter').should == 1
- @r.incr('counter').should == 2
- @r.incr('counter').should == 3
- @r.decr('counter').should == 2
- @r.decr('counter', 2).should == 0
- end
- #
- it "should be able to RANDKEY" do
- @r.randkey.should_not be_nil
- end
- #
- it "should be able to RENAME a key" do
- @r.del 'foo'
- @r.del'bar'
- @r['foo'] = 'hi'
- @r.rename 'foo', 'bar'
- @r['bar'].should == 'hi'
- end
- #
- it "should be able to RENAMENX a key" do
- @r.del 'foo'
- @r.del 'bar'
- @r['foo'] = 'hi'
- @r['bar'] = 'ohai'
- @r.renamenx 'foo', 'bar'
- @r['bar'].should == 'ohai'
- end
- #
- it "should be able to get DBSIZE of the database" do
- @r.delete 'foo'
- dbsize_without_foo = @r.dbsize
- @r['foo'] = 0
- dbsize_with_foo = @r.dbsize
-
- dbsize_with_foo.should == dbsize_without_foo + 1
- end
- #
- it "should be able to EXPIRE a key" do
- @r['foo'] = 'bar'
- @r.expire 'foo', 1
- @r['foo'].should == "bar"
- sleep 2
- @r['foo'].should == nil
- end
- #
- it "should be able to EXISTS" do
- @r['foo'] = 'nik'
- @r.exists('foo').should be_true
- @r.del 'foo'
- @r.exists('foo').should be_false
- end
- #
- it "should be able to KEYS" do
- @r.keys("f*").each { |key| @r.del key }
- @r['f'] = 'nik'
- @r['fo'] = 'nak'
- @r['foo'] = 'qux'
- @r.keys("f*").sort.should == ['f','fo', 'foo'].sort
- end
- #
- it "should be able to return a random key (RANDOMKEY)" do
- 3.times { @r.exists(@r.randomkey).should be_true }
- end
- #
- it "should be able to check the TYPE of a key" do
- @r['foo'] = 'nik'
- @r.type('foo').should == "string"
- @r.del 'foo'
- @r.type('foo').should == "none"
- end
- #
- it "should be able to push to the head of a list (LPUSH)" do
- @r.lpush "list", 'hello'
- @r.lpush "list", 42
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lpop('list').should == '42'
- end
- #
- it "should be able to push to the tail of a list (RPUSH)" do
- @r.rpush "list", 'hello'
- @r.type('list').should == "list"
- @r.llen('list').should == 1
- end
- #
- it "should be able to pop the tail of a list (RPOP)" do
- @r.rpush "list", 'hello'
- @r.rpush"list", 'goodbye'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.rpop('list').should == 'goodbye'
- end
- #
- it "should be able to pop the head of a list (LPOP)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lpop('list').should == 'hello'
- end
- #
- it "should be able to get the length of a list (LLEN)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- end
- #
- it "should be able to get a range of values from a list (LRANGE)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.rpush "list", '1'
- @r.rpush "list", '2'
- @r.rpush "list", '3'
- @r.type('list').should == "list"
- @r.llen('list').should == 5
- @r.lrange('list', 2, -1).should == ['1', '2', '3']
- end
- #
- it "should be able to trim a list (LTRIM)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.rpush "list", '1'
- @r.rpush "list", '2'
- @r.rpush "list", '3'
- @r.type('list').should == "list"
- @r.llen('list').should == 5
- @r.ltrim 'list', 0, 1
- @r.llen('list').should == 2
- @r.lrange('list', 0, -1).should == ['hello', 'goodbye']
- end
- #
- it "should be able to get a value by indexing into a list (LINDEX)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lindex('list', 1).should == 'goodbye'
- end
- #
- it "should be able to set a value by indexing into a list (LSET)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'hello'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lset('list', 1, 'goodbye').should == 'OK'
- @r.lindex('list', 1).should == 'goodbye'
- end
- #
- it "should be able to remove values from a list (LREM)" do
- @r.rpush "list", 'hello'
- @r.rpush "list", 'goodbye'
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lrem('list', 1, 'hello').should == 1
- @r.lrange('list', 0, -1).should == ['goodbye']
- end
- #
- it "should be able add members to a set (SADD)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.type('set').should == "set"
- @r.scard('set').should == 2
- @r.smembers('set').sort.should == ['key1', 'key2'].sort
- end
- #
- it "should be able delete members to a set (SREM)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.type('set').should == "set"
- @r.scard('set').should == 2
- @r.smembers('set').sort.should == ['key1', 'key2'].sort
- @r.srem('set', 'key1')
- @r.scard('set').should == 1
- @r.smembers('set').should == ['key2']
- end
- #
- it "should be able count the members of a set (SCARD)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.type('set').should == "set"
- @r.scard('set').should == 2
- end
- #
- it "should be able test for set membership (SISMEMBER)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.type('set').should == "set"
- @r.scard('set').should == 2
- @r.sismember('set', 'key1').should be_true
- @r.sismember('set', 'key2').should be_true
- @r.sismember('set', 'notthere').should be_false
- end
- #
- it "should be able to do set intersection (SINTER)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.sadd "set2", 'key2'
- @r.sinter('set', 'set2').should == ['key2']
- end
- #
- it "should be able to do set intersection and store the results in a key (SINTERSTORE)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.sadd "set2", 'key2'
- @r.sinterstore('newone', 'set', 'set2').should == 1
- @r.smembers('newone').should == ['key2']
- end
- #
- it "should be able to do set union (SUNION)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.sadd "set2", 'key2'
- @r.sadd "set2", 'key3'
- @r.sunion('set', 'set2').sort.should == ['key1','key2','key3'].sort
- end
- #
- it "should be able to do set union and store the results in a key (SUNIONSTORE)" do
- @r.sadd "set", 'key1'
- @r.sadd "set", 'key2'
- @r.sadd "set2", 'key2'
- @r.sadd "set2", 'key3'
- @r.sunionstore('newone', 'set', 'set2').should == 3
- @r.smembers('newone').sort.should == ['key1','key2','key3'].sort
- end
- #
- it "should be able to do set difference (SDIFF)" do
- @r.sadd "set", 'a'
- @r.sadd "set", 'b'
- @r.sadd "set2", 'b'
- @r.sadd "set2", 'c'
- @r.sdiff('set', 'set2').should == ['a']
- end
- #
- it "should be able to do set difference and store the results in a key (SDIFFSTORE)" do
- @r.sadd "set", 'a'
- @r.sadd "set", 'b'
- @r.sadd "set2", 'b'
- @r.sadd "set2", 'c'
- @r.sdiffstore('newone', 'set', 'set2')
- @r.smembers('newone').should == ['a']
- end
- #
- it "should be able move elements from one set to another (SMOVE)" do
- @r.sadd 'set1', 'a'
- @r.sadd 'set1', 'b'
- @r.sadd 'set2', 'x'
- @r.smove('set1', 'set2', 'a').should be_true
- @r.sismember('set2', 'a').should be_true
- @r.delete('set1')
- end
- #
- it "should be able to do crazy SORT queries" do
- # The 'Dogs' is capitialized on purpose
- @r['dog_1'] = 'louie'
- @r.rpush 'Dogs', 1
- @r['dog_2'] = 'lucy'
- @r.rpush 'Dogs', 2
- @r['dog_3'] = 'max'
- @r.rpush 'Dogs', 3
- @r['dog_4'] = 'taj'
- @r.rpush 'Dogs', 4
- @r.sort('Dogs', :get => 'dog_*', :limit => [0,1]).should == ['louie']
- @r.sort('Dogs', :get => 'dog_*', :limit => [0,1], :order => 'desc alpha').should == ['taj']
- end
-
- it "should be able to handle array of :get using SORT" do
- @r['dog:1:name'] = 'louie'
- @r['dog:1:breed'] = 'mutt'
- @r.rpush 'dogs', 1
- @r['dog:2:name'] = 'lucy'
- @r['dog:2:breed'] = 'poodle'
- @r.rpush 'dogs', 2
- @r['dog:3:name'] = 'max'
- @r['dog:3:breed'] = 'hound'
- @r.rpush 'dogs', 3
- @r['dog:4:name'] = 'taj'
- @r['dog:4:breed'] = 'terrier'
- @r.rpush 'dogs', 4
- @r.sort('dogs', :get => ['dog:*:name', 'dog:*:breed'], :limit => [0,1]).should == ['louie', 'mutt']
- @r.sort('dogs', :get => ['dog:*:name', 'dog:*:breed'], :limit => [0,1], :order => 'desc alpha').should == ['taj', 'terrier']
- end
- #
- it "should provide info (INFO)" do
- [:last_save_time, :redis_version, :total_connections_received, :connected_clients, :total_commands_processed, :connected_slaves, :uptime_in_seconds, :used_memory, :uptime_in_days, :changes_since_last_save].each do |x|
- @r.info.keys.should include(x)
- end
- end
- #
- it "should be able to flush the database (FLUSHDB)" do
- @r['key1'] = 'keyone'
- @r['key2'] = 'keytwo'
- @r.keys('*').sort.should == ['foo', 'key1', 'key2'].sort #foo from before
- @r.flushdb
- @r.keys('*').should == []
- end
- #
- it "should raise exception when manually try to change the database" do
- lambda { @r.select(0) }.should raise_error
- end
- #
- it "should be able to provide the last save time (LASTSAVE)" do
- savetime = @r.lastsave
- Time.at(savetime).class.should == Time
- Time.at(savetime).should <= Time.now
- end
-
- it "should be able to MGET keys" do
- @r['foo'] = 1000
- @r['bar'] = 2000
- @r.mget('foo', 'bar').should == ['1000', '2000']
- @r.mget('foo', 'bar', 'baz').should == ['1000', '2000', nil]
- end
-
- it "should be able to mapped MGET keys" do
- @r['foo'] = 1000
- @r['bar'] = 2000
- @r.mapped_mget('foo', 'bar').should == { 'foo' => '1000', 'bar' => '2000'}
- @r.mapped_mget('foo', 'baz', 'bar').should == { 'foo' => '1000', 'bar' => '2000'}
- end
-
- it "should bgsave" do
- @r.bgsave.should == 'OK'
- end
-
- it "should be able to ECHO" do
- @r.echo("message in a bottle\n").should == "message in a bottle\n"
- end
-
- it "should raise error when invoke MONITOR" do
- lambda { @r.monitor }.should raise_error
- end
-
- it "should raise error when invoke SYNC" do
- lambda { @r.sync }.should raise_error
- end
-
- it "should handle multiple servers" do
- require 'dist_redis'
- @r = DistRedis.new(:hosts=> ['localhost:6379', '127.0.0.1:6379'], :db => 15)
-
- 100.times do |idx|
- @r[idx] = "foo#{idx}"
- end
-
- 100.times do |idx|
- @r[idx].should == "foo#{idx}"
- end
- end
-
- it "should be able to pipeline writes" do
- @r.pipelined do |pipeline|
- pipeline.lpush 'list', "hello"
- pipeline.lpush 'list', 42
- end
-
- @r.type('list').should == "list"
- @r.llen('list').should == 2
- @r.lpop('list').should == '42'
- end
-
- it "should AUTH when connecting with a password" do
- r = Redis.new(:password => 'secret')
- r.stub!(:connect_to)
- r.should_receive(:call_command).with(['auth', 'secret'])
- r.connect_to_server
- end
-
-end
diff --git a/client-libraries/ruby/spec/spec_helper.rb b/client-libraries/ruby/spec/spec_helper.rb
deleted file mode 100644
index da70fe705..000000000
--- a/client-libraries/ruby/spec/spec_helper.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'rubygems'
-$TESTING=true
-$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
-require 'redis'
diff --git a/client-libraries/ruby/speed.rb b/client-libraries/ruby/speed.rb
deleted file mode 100644
index 51e58110e..000000000
--- a/client-libraries/ruby/speed.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'benchmark'
-require "#{File.dirname(__FILE__)}/lib/redis"
-
-r = Redis.new
-n = (ARGV.shift || 20000).to_i
-
-elapsed = Benchmark.realtime do
- # n sets, n gets
- n.times do |i|
- key = "foo#{i}"
- r[key] = key * 10
- r[key]
- end
-end
-
-puts '%.2f Kops' % (2 * n / 1000 / elapsed)
diff --git a/client-libraries/ruby/tasks/redis.tasks.rb b/client-libraries/ruby/tasks/redis.tasks.rb
deleted file mode 100644
index ed317d386..000000000
--- a/client-libraries/ruby/tasks/redis.tasks.rb
+++ /dev/null
@@ -1,125 +0,0 @@
-# Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
-require 'fileutils'
-require 'open-uri'
-
-class RedisRunner
-
- def self.redisdir
- "/tmp/redis/"
- end
-
- def self.redisconfdir
- '/etc/redis.conf'
- end
-
- def self.dtach_socket
- '/tmp/redis.dtach'
- end
-
- # Just check for existance of dtach socket
- def self.running?
- File.exists? dtach_socket
- end
-
- def self.start
- puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
- sleep 3
- exec "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
- end
-
- def self.attach
- exec "dtach -a #{dtach_socket}"
- end
-
- def self.stop
- sh 'echo "SHUTDOWN" | nc localhost 6379'
- end
-
-end
-
-namespace :redis do
-
- desc 'About redis'
- task :about do
- puts "\nSee http://code.google.com/p/redis/ for information about redis.\n\n"
- end
-
- desc 'Start redis'
- task :start do
- RedisRunner.start
- end
-
- desc 'Stop redis'
- task :stop do
- RedisRunner.stop
- end
-
- desc 'Restart redis'
- task :restart do
- RedisRunner.stop
- RedisRunner.start
- end
-
- desc 'Attach to redis dtach socket'
- task :attach do
- RedisRunner.attach
- end
-
- desc 'Install the lastest verison of Redis from Github (requires git, duh)'
- task :install => [:about, :download, :make] do
- %w(redis-benchmark redis-cli redis-server).each do |bin|
- sh "sudo cp /tmp/redis/#{bin} /usr/bin/"
- end
-
- puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/"
-
- unless File.exists?('/etc/redis.conf')
- sh 'sudo cp /tmp/redis/redis.conf /etc/'
- puts "Installed redis.conf to /etc/ \n You should look at this file!"
- end
- end
-
- task :make do
- sh "cd #{RedisRunner.redisdir} && make clean"
- sh "cd #{RedisRunner.redisdir} && make"
- end
-
- desc "Download package"
- task :download do
- sh 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}/.svn")
- sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?(RedisRunner.redisdir)
- sh "cd #{RedisRunner.redisdir} && git pull" if File.exists?("#{RedisRunner.redisdir}/.git")
- end
-
-end
-
-namespace :dtach do
-
- desc 'About dtach'
- task :about do
- puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
- end
-
- desc 'Install dtach 0.8 from source'
- task :install => [:about] do
-
- Dir.chdir('/tmp/')
- unless File.exists?('/tmp/dtach-0.8.tar.gz')
- require 'net/http'
-
- url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
- open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
- end
-
- unless File.directory?('/tmp/dtach-0.8')
- system('tar xzf dtach-0.8.tar.gz')
- end
-
- Dir.chdir('/tmp/dtach-0.8/')
- sh 'cd /tmp/dtach-0.8/ && ./configure && make'
- sh 'sudo cp /tmp/dtach-0.8/dtach /usr/bin/'
-
- puts 'Dtach successfully installed to /usr/bin.'
- end
-end
-
diff --git a/client-libraries/scala/.gitignore b/client-libraries/scala/.gitignore
deleted file mode 100644
index f38e2ab95..000000000
--- a/client-libraries/scala/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-.DS_Store
-lib_managed
-project/boot
-target
-target/
-target/**/*
diff --git a/client-libraries/scala/README.md b/client-libraries/scala/README.md
deleted file mode 100644
index afb28bf12..000000000
--- a/client-libraries/scala/README.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Redis Scala client
-
-## Key features of the library
-
-- Native Scala types Set and List responses.
-- Consisten Hashing on the client.
-- Support for Clustering of Redis nodes.
-
-## Information about redis
-
-Redis is a key-value database. It is similar to memcached but the dataset is not volatile, and values can be strings, exactly like in memcached, but also lists and sets with atomic operations to push/pop elements.
-
-http://code.google.com/p/redis/
-
-### Key features of Redis
-
-- Fast in-memory store with asynchronous save to disk.
-- Key value get, set, delete, etc.
-- Atomic operations on sets and lists, union, intersection, trim, etc.
-
-## Requirements
-
-- sbt (get it at http://code.google.com/p/simple-build-tool/)
-
-## Usage
-
-Start your redis instance (usually redis-server will do it)
-
- $ cd scala-redis
- $ sbt
- > update
- > test (optional to run the tests)
- > console
-
-And you are ready to start issuing commands to the server(s)
-
-let's connect and get a key:
-
- scala> import com.redis._
- scala> val r = new Redis("localhost", 6379)
- scala> val r.set("key", "some value")
- scala> val r.get("key")
-
-
-Alejandro Crosa <>
-
diff --git a/client-libraries/scala/project/build.properties b/client-libraries/scala/project/build.properties
deleted file mode 100644
index 22da51f98..000000000
--- a/client-libraries/scala/project/build.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-#Project properties
-#Wed Aug 19 07:54:05 ART 2009
-project.organization=com.redis
-project.name=RedisClient
-sbt.version=0.5.1
-project.version=1.0.1
-scala.version=2.7.5
-project.initialize=false
diff --git a/client-libraries/scala/project/build/RedisClientProject.scala b/client-libraries/scala/project/build/RedisClientProject.scala
deleted file mode 100644
index 60dff43b0..000000000
--- a/client-libraries/scala/project/build/RedisClientProject.scala
+++ /dev/null
@@ -1,12 +0,0 @@
-import sbt._
-
-class RedisClientProject(info: ProjectInfo) extends DefaultProject(info) with AutoCompilerPlugins
-{
- override def useDefaultConfigurations = true
-
- val scalatest = "org.scala-tools.testing" % "scalatest" % "0.9.5" % "test->default"
- val specs = "org.scala-tools.testing" % "specs" % "1.5.0"
- val mockito = "org.mockito" % "mockito-all" % "1.7"
- val junit = "junit" % "junit" % "4.5"
- val sxr = compilerPlugin("org.scala-tools.sxr" %% "sxr" % "0.2.1")
-}
diff --git a/client-libraries/scala/src/main/scala/com/redis/Connection.scala b/client-libraries/scala/src/main/scala/com/redis/Connection.scala
deleted file mode 100644
index d4b51ed7d..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Connection.scala
+++ /dev/null
@@ -1,8 +0,0 @@
-package com.redis
-
-/**
- * Redis client Connection
- *
- */
-
-case class Connection(val host: String, val port: Int) extends SocketOperations
diff --git a/client-libraries/scala/src/main/scala/com/redis/HashRing.scala b/client-libraries/scala/src/main/scala/com/redis/HashRing.scala
deleted file mode 100644
index e16cc1825..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/HashRing.scala
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.redis
-
-/**
- * Hash Ring
- *
- */
-
-import java.util.zip.CRC32
-import scala.collection.mutable.ArrayBuffer
-import scala.collection.mutable.Map
-
-trait HashRing {
-
- val replicas: Int
-
- var sortedKeys: List[Long] = List()
- var cluster = new ArrayBuffer[Redis]
- val ring = Map[Long, Redis]()
-
- // Adds the node to the hashRing
- // including a number of replicas.
- def addNode(node: Redis) = {
- cluster += node
- (1 to replicas).foreach{ replica =>
- val key = calculateChecksum(node+":"+replica)
- ring += (key -> node)
- sortedKeys = sortedKeys ::: List(key)
- }
- sortedKeys = sortedKeys.sort(_ < _)
- }
-
- // get the node in the hash ring for this key
- def getNode(key: String) = getNodePos(key)._1
-
- def getNodePos(key: String): (Redis, Int) = {
- val crc = calculateChecksum(key)
- val idx = binarySearch(crc)
- (ring(sortedKeys(idx)), idx)
- }
-
- // TODO this should perform a Bynary search
- def binarySearch(value: Long): Int = {
- var upper = (sortedKeys.length -1)
- var lower = 0
- var idx = 0
- var comp: Long = 0
-
- while(lower <= upper){
- idx = (lower + upper) / 2
- comp = sortedKeys(idx)
-
- if(comp == value) { return idx }
- if(comp < value) { upper = idx -1 }
- if(comp > value) { lower = idx +1 }
- }
- return upper
- }
-
- // Computes the CRC-32 of the given String
- def calculateChecksum(value: String): Long = {
- val checksum = new CRC32
- checksum.update(value.getBytes)
- checksum.getValue
- }
-}
-
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/KeySpaceOperations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/KeySpaceOperations.scala
deleted file mode 100644
index 13dc593cc..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/KeySpaceOperations.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis key space operations
- *
- */
-
-trait KeySpaceOperations{
-
- val connection: Connection
- var db: Int
-
- // KEYS
- // returns all the keys matching the glob-style pattern.
- def keys(pattern: String): Array[String] = {
- connection.write("KEYS "+pattern+"\r\n")
- connection.readResponse.toString.split(" ")
- }
-
- // RANDKEY
- // return a randomly selected key from the currently selected DB.
- def randomKey: String = {
- connection.write("RANDOMKEY\r\n")
- connection.readResponse.toString.split('+')(1)
- }
-
- // RENAME (oldkey, newkey)
- // atomically renames the key oldkey to newkey.
- def rename(oldkey: String, newkey: String): Boolean = {
- connection.write("RENAME "+oldkey+" "+newkey+"\r\n")
- connection.readBoolean
- }
-
- // RENAMENX (oldkey, newkey)
- // rename oldkey into newkey but fails if the destination key newkey already exists.
- def renamenx(oldkey: String, newkey: String): Boolean = {
- connection.write("RENAMENX "+oldkey+" "+newkey+"\r\n")
- connection.readBoolean
- }
-
- // DBSIZE
- // return the size of the db.
- def dbSize: Int = {
- connection.write("DBSIZE\r\n")
- connection.readInt
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/ListOperations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/ListOperations.scala
deleted file mode 100644
index 6538311b4..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/ListOperations.scala
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis list operations
- *
- */
-
-trait ListOperations{
-
- def getConnection(key: String): Connection
-
- // add the string value to the head (LPUSH) or tail (RPUSH) of the list stored at key.
- // If the key does not exist an empty list is created just before the append operation. If the key exists but is not a List an error is returned.
- // LPUSH
- def pushHead(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("LPUSH "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // RPUSH
- def pushTail(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("RPUSH "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // LPOP
- // atomically return and remove the first (LPOP) or last (RPOP) element of the list
- def popHead(key: String): String = {
- val connection = getConnection(key)
- connection.write("LPOP "+key+"\r\n")
- connection.readString
- }
-
- // RPOP
- // atomically return and remove the first (LPOP) or last (RPOP) element of the list
- def popTail(key: String): String = {
- val connection = getConnection(key)
- connection.write("RPOP "+key+"\r\n")
- connection.readString
- }
-
- // LINDEX
- // return the especified element of the list stored at the specified key. 0 is the first element, 1 the second and so on.
- // Negative indexes are supported, for example -1 is the last element, -2 the penultimate and so on.
- def listIndex(key: String, index: Int): String = {
- val connection = getConnection(key)
- connection.write("LINDEX "+key+" "+index+"\r\n")
- connection.readString
- }
-
- // LSET
- // set the list element at index with the new value. Out of range indexes will generate an error
- def listSet(key: String, index: Int, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("LSET "+key+" "+index+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // LLEN
- // return the length of the list stored at the specified key.
- // If the key does not exist zero is returned (the same behaviour as for empty lists). If the value stored at key is not a list an error is returned.
- def listLength(key: String): Int = {
- val connection = getConnection(key)
- connection.write("LLEN "+key+"\r\n")
- connection.readInt
- }
-
- // LRANGE
- // return the specified elements of the list stored at the specified key.
- // Start and end are zero-based indexes. 0 is the first element of the list (the list head), 1 the next element and so on.
- def listRange(key: String, start: Int, end: Int): List[String] = {
- val connection = getConnection(key)
- connection.write("LRANGE "+key+" "+start+" "+end+"\r\n")
- connection.readList
- }
-
- // LTRIM
- // Trim an existing list so that it will contain only the specified range of elements specified.
- def listTrim(key: String, start: Int, end: Int): Boolean = {
- val connection = getConnection(key)
- connection.write("LTRIM "+key+" "+start+" "+end+"\r\n")
- connection.readBoolean
- }
-
- // LREM
- // Remove the first count occurrences of the value element from the list.
- def listRem(key: String, count: Int, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("LREM "+key+" "+count+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-}
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/NodeOperations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/NodeOperations.scala
deleted file mode 100644
index 3deb8dd01..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/NodeOperations.scala
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis node operations
- *
- */
-
-trait NodeOperations {
-
- val connection: Connection
- var db: Int
-
- // SAVE
- // save the DB on disk now.
- def save: Boolean = {
- connection.write("SAVE\r\n")
- connection.readBoolean
- }
-
- // BGSAVE
- // save the DB in the background.
- def bgSave: Boolean = {
- connection.write("BGSAVE\r\n")
- connection.readBoolean
- }
-
- // LASTSAVE
- // return the UNIX TIME of the last DB SAVE executed with success.
- def lastSave: Int = {
- connection.write("LASTSAVE\r\n")
- connection.readInt
- }
-
- // SHUTDOWN
- // Stop all the clients, save the DB, then quit the server.
- def shutdown: Boolean = {
- connection.write("SHUTDOWN\r\n")
- connection.readBoolean
- }
-
- // MGET (key, key, key, ...)
- // get the values of all the specified keys.
- def mget(keys: String*) = {
- connection.write("MGET "+keys.mkString(" ")+"\r\n")
- connection.readList
- }
-
- // INFO
- // the info command returns different information and statistics about the server.
- def info = {
- connection.write("INFO\r\n")
- connection.readResponse
- }
-
- // MONITOR
- // is a debugging command that outputs the whole sequence of commands received by the Redis server.
- def monitor: Boolean = {
- connection.write("MONITOR\r\n")
- connection.readBoolean
- }
-
- // SLAVEOF
- // The SLAVEOF command can change the replication settings of a slave on the fly.
- def slaveOf(options: Any): Boolean = options match {
- case (host: String, port: Int) => {
- connection.write("SLAVEOF "+host+" "+port.toString+"\r\n")
- connection.readBoolean
- }
- case _ => setAsMaster
- }
-
- def setAsMaster: Boolean = {
- connection.write("SLAVEOF NO ONE\r\n")
- connection.readBoolean
- }
-
- // SELECT (index)
- // selects the DB to connect, defaults to 0 (zero).
- def selectDb(index: Int): Boolean = {
- connection.write("SELECT "+index+"\r\n")
- connection.readBoolean match {
- case true => { db = index; true }
- case _ => false
- }
- }
-
- // FLUSHDB the DB
- // removes all the DB data.
- def flushDb: Boolean = {
- connection.write("FLUSHDB\r\n")
- connection.readBoolean
- }
-
- // FLUSHALL the DB's
- // removes data from all the DB's.
- def flushAll: Boolean = {
- connection.write("FLUSHALL\r\n")
- connection.readBoolean
- }
-
- // MOVE
- // Move the specified key from the currently selected DB to the specified destination DB.
- def move(key: String, db: Int) = {
- connection.write("MOVE "+key+" "+db.toString+"\r\n")
- connection.readBoolean
- }
-
- // QUIT
- // exits the server.
- def quit: Boolean = {
- connection.write("QUIT\r\n")
- connection.disconnect
- }
-
- // AUTH
- // auths with the server.
- def auth(secret: String): Boolean = {
- connection.write("AUTH "+secret+"\r\n")
- connection.readBoolean
- }
-}
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/Operations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/Operations.scala
deleted file mode 100644
index fb5c23d6a..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/Operations.scala
+++ /dev/null
@@ -1,124 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis operations
- *
- */
-
-trait Operations{
-
- def getConnection(key: String): Connection
-
- // SET (key, value)
- // SET (key, value, expiry)
- // sets the key with the specified value, and with an optional expiry.
- def set(key: String, value: String) = setKey(key, value)
- def set(key: String, value: String, expiry: Int) = { setKey(key, value) && expire(key, expiry) }
-
- // SET KEY (key, value)
- // sets the key with the specified value.
- def setKey(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("SET "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // EXPIRE (key, expiry)
- // sets the expire time (in sec.) for the specified key.
- def expire(key: String, expiry: Int): Boolean = {
- val connection = getConnection(key)
- connection.write("EXPIRE "+key+" "+expiry+"\r\n")
- connection.readBoolean
- }
-
- // GET (key)
- // gets the value for the specified key.
- def get(key: String): String = {
- val connection = getConnection(key)
- val a = connection.write("GET "+key+"\r\n")
- connection.readResponse match {
- case r: String => r.toString
- case _ => null
- }
- }
-
- // GETSET (key, value)
- // is an atomic set this value and return the old value command.
- def getSet(key: String, value: String): String = {
- val connection = getConnection(key)
- val a = connection.write("GETSET "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readResponse match {
- case r: String => r.toString
- case _ => null
- }
- }
-
- // SETNX (key, value)
- // sets the value for the specified key, only if the key is not there.
- def setUnlessExists(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("SETNX "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // DELETE (key)
- // deletes the specified key.
- def delete(key: String): Boolean = {
- val connection = getConnection(key)
- connection.write("DEL "+key+"\r\n")
- connection.readBoolean
- }
-
- // INCR (key)
- // INCR (key, increment)
- // increments the specified key, optional the increment value.
- def incr(x: Any): Int = x match {
- case (key: String, increment: Int) => incrBy(key, increment)
- case (key: String) => incrOne(key)
- case _ => 0
- }
- def incrBy(key: String, increment: Int): Int = {
- val connection = getConnection(key)
- connection.write("INCRBY "+key+" "+increment+"\r\n")
- connection.readInt
- }
- def incrOne(key: String): Int = {
- val connection = getConnection(key)
- connection.write("INCR "+key+"\r\n")
- connection.readInt
- }
-
- // DECR (key)
- // DECRBY (key, decrement)
- // decrements the specified key, optional the decrement value.
- def decr(key: String, decrement: Int) = decrBy(key, decrement)
- def decr(key: String) = decrOne(key)
-
- def decrBy(key: String, decrement: Int): Int = {
- val connection = getConnection(key)
- connection.write("DECRBY "+key+" "+decrement+"\r\n")
- connection.readInt
- }
- def decrOne(key: String): Int = {
- val connection = getConnection(key)
- connection.write("DECR "+key+"\r\n")
- connection.readInt
- }
-
- // EXISTS (key)
- // test if the specified key exists.
- def exists(key: String): Boolean = {
- val connection = getConnection(key)
- connection.write("EXISTS "+key+"\r\n")
- connection.readBoolean
- }
-
- // TYPE (key)
- // return the type of the value stored at key in form of a string.
- def getType(key: String): Any = {
- val connection = getConnection(key)
- connection.write("TYPE "+key+"\r\n")
- connection.readResponse
- }
-
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/SetOperations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/SetOperations.scala
deleted file mode 100644
index 13432d35a..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/SetOperations.scala
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis set operations
- *
- */
-
-trait SetOperations{
-
- def getConnection(key: String): Connection
-
- // SADD
- // Add the specified member to the set value stored at key.
- def setAdd(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("SADD "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // SREM
- // Remove the specified member from the set value stored at key.
- def setDelete(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("SREM "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // SCARD
- // Return the number of elements (the cardinality) of the Set at key.
- def setCount(key: String): Int = {
- val connection = getConnection(key)
- connection.write("SCARD "+key+"\r\n")
- connection.readInt
- }
-
- // SMEMBERS
- // Return all the members of the Set value at key.
- def setMembers(key: String): Set[String] = {
- val connection = getConnection(key)
- connection.write("SMEMBERS "+key+"\r\n")
- connection.readSet
- }
-
- // SPOP
- // Remove and return (pop) a random element from the Set value at key.
- def setPop(key: String): String = {
- val connection = getConnection(key)
- connection.write("SPOP "+key+"\r\n")
- connection.readString
- }
-
- // SMOVE
- // Move the specified member from one Set to another atomically.
- def setMove(sourceKey: String, destKey: String, value: String): Boolean = {
- val connection = getConnection(sourceKey)
- connection.write("SMOVE "+sourceKey+" "+destKey+" "+value+"\r\n")
- connection.readBoolean
- }
-
- // SISMEMBER
- // Test if the specified value is a member of the Set at key.
- def setMemberExists(key: String, value: String): Boolean = {
- val connection = getConnection(key)
- connection.write("SISMEMBER "+key+" "+value.length+"\r\n"+value+"\r\n")
- connection.readBoolean
- }
-
- // SINTER
- // Return the intersection between the Sets stored at key1, key2, ..., keyN.
- def setIntersect(keys: String*): Set[String] = {
- val connection = getConnection(keys(0))
- connection.write("SINTER "+keys.mkString(" ")+"\r\n")
- connection.readSet
- }
-
- // SINTERSTORE
- // Compute the intersection between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey.
- def setInterStore(key: String, keys: String*): Boolean = {
- val connection = getConnection(key)
- connection.write("SINTERSTORE "+key+" "+keys.mkString(" ")+"\r\n")
- connection.readBoolean
- }
-
- // SDIFF
- // Return the difference between the Set stored at key1 and all the Sets key2, ..., keyN.
- def setDiff(keys: String*): Set[String] = {
- val connection = getConnection(keys(0))
- connection.write("SDIFF "+keys.mkString(" ")+"\r\n")
- connection.readSet
- }
-
- // SDIFFSTORE
- // Compute the difference between the Set key1 and all the Sets key2, ..., keyN, and store the resulting Set at dstkey.
- def setDiffStore(key: String, keys: String*): Boolean = {
- val connection = getConnection(key)
- connection.write("SDIFFSTORE "+key+" "+keys.mkString(" ")+"\r\n")
- connection.readBoolean
- }
-
- // SUNION
- // Return the union between the Sets stored at key1, key2, ..., keyN.
- def setUnion(keys: String*): Set[String] = {
- val connection = getConnection(keys(0))
- connection.write("SUNION "+keys.mkString(" ")+"\r\n")
- connection.readSet
- }
-
- // SUNIONSTORE
- // Compute the union between the Sets stored at key1, key2, ..., keyN, and store the resulting Set at dstkey.
- def setUnionStore(key: String, keys: String*): Boolean = {
- val connection = getConnection(key)
- connection.write("SUNIONSTORE "+key+" "+keys.mkString(" ")+"\r\n")
- connection.readBoolean
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/main/scala/com/redis/Operations/SortOperations.scala b/client-libraries/scala/src/main/scala/com/redis/Operations/SortOperations.scala
deleted file mode 100644
index f3d0ca14d..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/Operations/SortOperations.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.redis.operations
-
-/**
- * Redis sort operations
- *
- */
-
-trait SortOperations{
-
- def getConnection(key: String): Connection
-
- // SORT
- // Sort a Set or a List accordingly to the specified parameters.
- def sort(args: Any): List[String] = args match {
- case (key: String, command: String) => doSort(key, command)
- case (key: String) => doSort(key, "")
- }
-
- def doSort(key: String, command: String): List[String] = {
- val connection = getConnection(key)
- if(command != "") {
- connection.write("SORT "+key+" "+command+"\r\n")
- } else {
- connection.write("SORT "+key+"\r\n")
- }
- connection.readList
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/main/scala/com/redis/RedisClient.scala b/client-libraries/scala/src/main/scala/com/redis/RedisClient.scala
deleted file mode 100644
index ac051cc58..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/RedisClient.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.redis
-
-import com.redis.operations._
-
-/**
- * Redis client
- *
- */
-
-class Redis(val host: String, val port: Int) extends Operations with ListOperations with SetOperations with NodeOperations with KeySpaceOperations with SortOperations {
-
- // auxiliary constructor
- def this() = this("localhost", 6379)
-
- // Points to the connection to a server instance
- val connection = Connection(host, port)
- var db: Int = 0
-
- // Connect and Disconnect to the Redis server
- def connect = connection.connect
- def disconnect = connection.disconnect
- def connected: Boolean = connection.connected
-
- // Establish the connection to the server instance on initialize
- connect
-
- // Get Redis Client connection.
- def getConnection(key: String) = getConnection
- def getConnection = connection
-
- // Outputs a formatted representation of the Redis server.
- override def toString = connection.host+":"+connection.port+" "
-}
diff --git a/client-libraries/scala/src/main/scala/com/redis/RedisCluster.scala b/client-libraries/scala/src/main/scala/com/redis/RedisCluster.scala
deleted file mode 100644
index 0a753719e..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/RedisCluster.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.redis
-
-import com.redis.operations._
-
-/**
- * Redis cluster
- *
- */
-
-import scala.collection.mutable.ArrayBuffer
-
-class RedisCluster(val hosts: String*) extends Operations with ListOperations with SetOperations with HashRing with SortOperations {
-
- // Get Redis Client connection inside the HashRing.
- def getConnection(key: String) = {
- getNode(key).connection
- }
-
- // Default value used on MemCache client.
- private val NUMBER_OF_REPLICAS = 160
- val replicas = NUMBER_OF_REPLICAS
-
- // Outputs a formatted representation of the Redis server.
- override def toString = cluster.mkString(", ")
-
- // Connect the client and add it to the cluster.
- def connectClient(host: String): Boolean = {
- val h = host.split(":")(0)
- val p = host.split(":")(1)
- val client = new Redis(h.toString, p.toString.toInt)
- addNode(client)
- client.connected
- }
-
- // Connect all clients in the cluster.
- def connect = cluster.map(c => c.connect)
-
- // Initialize cluster.
- def initialize_cluster = hosts.map(connectClient(_))
-
- initialize_cluster
-}
diff --git a/client-libraries/scala/src/main/scala/com/redis/SocketOperations.scala b/client-libraries/scala/src/main/scala/com/redis/SocketOperations.scala
deleted file mode 100644
index 137ecae34..000000000
--- a/client-libraries/scala/src/main/scala/com/redis/SocketOperations.scala
+++ /dev/null
@@ -1,167 +0,0 @@
-package com.redis
-
-/**
- * Socket operations
- *
- */
-
-import java.io._
-import java.net.Socket
-
-trait SocketOperations {
-
- // Response codes from the Redis server
- // they tell you what's coming next from the server.
- val ERR: String = "-"
- val OK: String = "+OK"
- val SINGLE: String = "+"
- val BULK: String = "$"
- val MULTI: String = "*"
- val INT:String = ":"
-
- val host: String
- val port: Int
-
- // File descriptors.
- var socket: Socket = null
- var out: OutputStream = null
- var in: BufferedReader = null
-
- def getOutputStream: OutputStream = out
- def getInputStream: BufferedReader = in
- def getSocket: Socket = socket
-
- def connected = { getSocket != null }
- def reconnect = { disconnect && connect; }
-
- // Connects the socket, and sets the input and output streams.
- def connect: Boolean = {
- try {
- socket = new Socket(host, port)
- out = getSocket.getOutputStream
- in = new BufferedReader(new InputStreamReader(getSocket.getInputStream));
- true
- } catch {
- case _ => clear_fd; false;
- }
- }
-
- // Disconnects the socket.
- def disconnect: Boolean = {
- try {
- socket.close
- out.close
- in.close
- clear_fd
- true
- } catch {
- case _ => false
- }
- }
-
- def clear_fd = {
- socket = null
- out = null
- in = null
- }
-
- // Reads the server responses as Scala types.
- def readString: String = readResponse.toString // Reads the server response as an Int
- def readInt: Int = Integer.parseInt(readResponse.toString) // Reads the server response as an Int
- def readList: List[String] = listReply(readResponse.toString) // Reads the server response as a List
- def readSet: Set[String] = setReply(readResponse.toString) // Reads the server response as a String
- def readBoolean: Boolean = readResponse match {
- case 1 => true
- case OK => true
- case _ => false
- }
-
- // Read from Input Stream.
- def readline: String = {
- try {
- getInputStream.readLine()
- } catch {
- case _ => ERR;
- }
- }
-
- // Gets the type of response the server is going to send.
- def readtype = {
- val res = readline
- if(res !=null){
- (res(0).toString(), res)
- }else{
- ("-", "")
- }
- }
-
- // Reads the response from the server based on the response code.
- def readResponse = {
-
- val responseType = readtype
- try{
- responseType._1 match {
- case ERR => reconnect; // RECONNECT
- case SINGLE => lineReply(responseType._2)
- case BULK => bulkReply(responseType._2)
- case MULTI => responseType._2
- case INT => integerReply(responseType._2)
- case _ => reconnect; // RECONNECT
- }
- }catch{
- case e: Exception => false
- }
- }
-
- def integerReply(response: String): Int = Integer.parseInt(response.split(":")(1).toString)
-
- def lineReply(response: String): String = response
-
- def listReply(response: String): List[String] = {
- val total = Integer.parseInt(response.split('*')(1))
- var list: List[String] = List()
- for(i <- 1 to total){
- list = (list ::: List(bulkReply(readtype._2)))
- }
- list
- }
-
- def bulkReply(response: String) = {
- if(response(1).toString() != ERR){
- var length: Int = Integer.parseInt(response.split('$')(1).split("\r\n")(0))
- var line, res: String = ""
- while(length >= 0){
- line = readline
- length -= (line.length+2)
- res += line
- if(length > 0) res += "\r\n"
- }
- res
- }else{ null }
- }
-
- def setReply(response: String): Set[String] = {
- val total = Integer.parseInt(response.split('*')(1))
- var set: Set[String] = Set()
- for(i <- 1 to total){
- set += bulkReply(readtype._2)
- }
- set
- }
-
- // Wraper for the socket write operation.
- def write_to_socket(data: String)(op: OutputStream => Unit) = op(getOutputStream)
-
- // Writes data to a socket using the specified block.
- def write(data: String) = {
- if(!connected) connect;
- write_to_socket(data){
- getSocket =>
- try {
- getSocket.write(data.getBytes)
- } catch {
- case _ => reconnect;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/test/scala/com/redis/RedisClientSpec.scala b/client-libraries/scala/src/test/scala/com/redis/RedisClientSpec.scala
deleted file mode 100644
index 804a19aef..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/RedisClientSpec.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object RedisClientSpec extends Specification with Mockito {
-
- "Redis Client" should {
- var client: Redis = null
-
- "print formatted client status" in {
- client = new Redis("localhost", 121212)
- client.toString must be matching("localhost:121212 ")
- }
-
- "get the same connection when passing key para or not since it's a single node" in {
- client.getConnection("key") mustEqual client.getConnection
- }
-
- "use db zero as default" in {
- client.db mustEqual 0
- }
- }
-}
diff --git a/client-libraries/scala/src/test/scala/com/redis/RedisClusterSpec.scala b/client-libraries/scala/src/test/scala/com/redis/RedisClusterSpec.scala
deleted file mode 100644
index cee08d701..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/RedisClusterSpec.scala
+++ /dev/null
@@ -1,51 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object RedisClusterSpec extends Specification with Mockito {
-
- "Redis Cluster" should {
- var cluster: RedisCluster = null
- var mockedRedis: Redis = null
-
- doBefore {
- cluster = new RedisCluster("localhost:11221", "localhost:99991")
- mockedRedis = mock[Redis]
- }
-
- "print formatted client status" in {
- cluster.toString must be matching("localhost:11221 , localhost:99991 ")
- }
-
- "get the connection for the specified key" in {
- cluster.getConnection("key") mustEqual Connection("localhost", 99991)
- cluster.getConnection("anotherkey") mustEqual Connection("localhost", 11221)
- }
-
- "use the default number of replicas" in {
- cluster.replicas mustEqual 160
- }
-
- "initialize cluster" in {
- val initializedCluster = cluster.initialize_cluster
- initializedCluster.size mustEqual 2
- initializedCluster(0) mustEqual false
- initializedCluster(1) mustEqual false
- }
-
- "connect all the redis instances" in {
- cluster.cluster(1) = mockedRedis
-
- cluster.cluster(1).connect returns true
- val connectResult = cluster.connect
- connectResult.size mustEqual 2
- connectResult(0) mustEqual false
- connectResult(1) mustEqual true
- cluster.cluster(1).connect was called
- }
- }
-}
diff --git a/client-libraries/scala/src/test/scala/com/redis/SocketOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/SocketOperationsSpec.scala
deleted file mode 100644
index 4f7bbac4f..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/SocketOperationsSpec.scala
+++ /dev/null
@@ -1,97 +0,0 @@
-import org.specs._
-import com.redis._
-
-import java.io._
-import java.net.Socket
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-
-class SocketOperationTest(val host:String, val port: Int) extends SocketOperations
-
-object SocketOperationsSpec extends Specification with Mockito {
-
- "Socket Operations" should {
- var socketOperation: SocketOperationTest = null
- var socket: Socket = null
- var in: BufferedReader = null
-
- doBefore {
- socketOperation = new SocketOperationTest("localhost", 6379666)
- socket = mock[Socket]
- in = mock[BufferedReader]
- socketOperation.socket = socket
- socketOperation.in = in
- }
-
- def readOkFromInput = { when(in.readLine()).thenReturn(socketOperation.OK) }
- def readSingleFromInput = { when(in.readLine()).thenReturn(socketOperation.SINGLE) }
- def readBulkFromInput = { in.readLine() returns("$6\r\nfoobar\r\n") thenReturns("$6\r\nfoobar\r\n") }
- def readIntFromInput = { when(in.readLine()).thenReturn(socketOperation.INT+"666") }
-
- "tell if it's connected" in {
- socketOperation.connected mustEqual true
- socketOperation.socket = null
- socketOperation.connected mustEqual false
- }
-
- "return false when can't connect" in {
- socketOperation.connect mustEqual false
- }
-
- "return current data input stream" in {
- socketOperation.getInputStream mustEqual in
- }
-
- "read a line from socket" in {
- readOkFromInput
- socketOperation.in mustEqual in
- socketOperation.readline mustEqual socketOperation.OK
- }
-
- "read type response" in {
- readOkFromInput
- socketOperation.readtype mustEqual ("+", socketOperation.OK)
- }
-
- "when reading responses" in {
-
- "read OK" in {
- readOkFromInput
- socketOperation.readResponse mustEqual socketOperation.OK
- }
-
- "read single line" in {
- readSingleFromInput
- socketOperation.readResponse mustEqual socketOperation.SINGLE
- }
-
- "reconnect on error" in {
- socketOperation.readResponse mustEqual false
- socket.close was called
- socketOperation.connected mustEqual true
- }
-
- "read in bulk" in {
- // readBulkFromInput
- // this shouldn't be the response, it doesn't seem to work return and then returns.
- // Here's what should happen: '$6\r\n' on first readLine and then 'foobar\r\n'
- readBulkFromInput
- socketOperation.readtype mustEqual ("$", "$6\r\nfoobar\r\n")
- socketOperation.readResponse mustEqual "$6\r\nfoobar\r\n"
- socketOperation.bulkReply("$6\r\nfoobar\r\n") was called
- }
-
- "read integer" in {
- readIntFromInput
- socketOperation.readInt mustEqual 666
- }
-
- "read a boolean return value" in {
- readOkFromInput
- socketOperation.readBoolean mustEqual true
- }
- }
- }
-}
diff --git a/client-libraries/scala/src/test/scala/com/redis/helpers/RedisClientTestHelper.scala b/client-libraries/scala/src/test/scala/com/redis/helpers/RedisClientTestHelper.scala
deleted file mode 100644
index 402520ab4..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/helpers/RedisClientTestHelper.scala
+++ /dev/null
@@ -1,13 +0,0 @@
-import org.specs._
-import com.redis._
-import com.redis.operations._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-class RedisTestClient(val connection: Connection) extends Operations with ListOperations with SetOperations with NodeOperations with KeySpaceOperations with SortOperations {
- var db: Int = 0
- def getConnection(key: String): Connection = connection
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/KeySpaceOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/KeySpaceOperationsSpec.scala
deleted file mode 100644
index ced34fefa..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/KeySpaceOperationsSpec.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object KeySpaceOperationsSpec extends Specification with Mockito {
-
- "Redis Client Key Operations" should {
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "return all keys matching" in {
- connection.readResponse returns "akey anotherkey adiffkey"
- client.keys("a*")
- connection.write("KEYS a*\r\n") was called
- }
-
- "return a random key" in {
- connection.readResponse returns "+somerandonkey"
- client.randomKey mustEqual "somerandonkey"
- connection.write("RANDOMKEY\r\n") was called
- }
-
- "remame a key" in {
- connection.readBoolean returns true
- client.rename("a", "b") must beTrue
- connection.write("RENAME a b\r\n") was called
- }
-
- "rename a key only if destintation doesn't exist" in {
- connection.readBoolean returns false
- client.renamenx("a", "b") must beFalse
- connection.write("RENAMENX a b\r\n") was called
- }
-
- "tell the size of the db, # of keys" in {
- connection.readInt returns 4
- client.dbSize mustEqual 4
- connection.write("DBSIZE\r\n") was called
- }
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/ListOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/ListOperationsSpec.scala
deleted file mode 100644
index 95c66b55b..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/ListOperationsSpec.scala
+++ /dev/null
@@ -1,81 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object ListOperationsSpec extends Specification with Mockito {
-
- "Redis Client List Operations" should {
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "push to head" in {
- connection.readBoolean returns true
- client.pushHead("k", "v") must beTrue
- connection.write("LPUSH k 1\r\nv\r\n") was called
- }
-
- "push to tail" in {
- connection.readBoolean returns true
- client.pushTail("k", "v") must beTrue
- connection.write("RPUSH k 1\r\nv\r\n") was called
- }
-
- "pop from head" in {
- connection.readString returns "value"
- client.popHead("key") mustEqual "value"
- connection.write("LPOP key\r\n") was called
- }
-
- "pop from tail" in {
- connection.readString returns "value"
- client.popTail("key") mustEqual "value"
- connection.write("RPOP key\r\n") was called
- }
-
- "return list index" in {
- connection.readString returns "value"
- client.listIndex("k", 2) mustEqual "value"
- connection.write("LINDEX k 2\r\n") was called
- }
-
- "return set element at index" in {
- connection.readBoolean returns true
- client.listSet("k", 1, "value") mustEqual true
- connection.write("LSET k 1 5\r\nvalue\r\n") was called
- }
-
- "return list size" in {
- connection.readInt returns 3
- client.listLength("k") mustEqual 3
- connection.write("LLEN k\r\n") was called
- }
-
- "return list range" in {
- val listResult: List[String] = List("one", "two", "three", "four", "five")
- connection.readList returns listResult
- client.listRange("k", 2, 4) mustEqual listResult
- connection.write("LRANGE k 2 4\r\n") was called
- }
-
- "trim a list" in {
- connection.readBoolean returns true
- client.listTrim("k", 2, 4) mustEqual true
- connection.write("LTRIM k 2 4\r\n") was called
- }
-
- "remove occurrences of a value in the list" in {
- connection.readBoolean returns true
- client.listRem("k", 2, "value") mustEqual true
- connection.write("LREM k 2 5\r\nvalue\r\n") was called
- }
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/NodeOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/NodeOperationsSpec.scala
deleted file mode 100644
index 629c46353..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/NodeOperationsSpec.scala
+++ /dev/null
@@ -1,113 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object NodeOperationsSpec extends Specification with Mockito {
-
- "Redis Client Node Operations" should {
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "save the db to disk" in {
- connection.readBoolean returns true
- client.save must beTrue
- connection.write("SAVE\r\n") was called
- }
-
- "return the last time saved data to the db" in {
- connection.readInt returns 1250421891
- client.lastSave mustEqual 1250421891
- connection.write("LASTSAVE\r\n") was called
- }
-
- "return all specified keys" in {
- connection.readList returns List[String]("hola", null, null)
- client.mget("a", "b", "c") mustEqual List[String]("hola", null, null)
- connection.write("MGET a b c\r\n") was called
- }
-
- "return server info" in {
- val sampleInfo = "res0: Any = \nredis_version:0.091\nconnected_clients:2\nconnected_slaves:0\nused_memory:3036\nchanges_since_last_save:0\nlast_save_time:1250440893\ntotal_connections_received:2\ntotal_commands_processed:0\nuptime_in_seconds:7\nuptime_in_days:0\n"
- connection.readResponse returns sampleInfo
- client.info mustEqual sampleInfo
- connection.write("INFO\r\n") was called
- }
-
- "start monitor debug on the server" in {
- connection.readBoolean returns true
- client.monitor mustEqual true
- connection.write("MONITOR\r\n") was called
- }
-
- "set a server as slave of a remote master" in {
- connection.readBoolean returns true
- client.slaveOf("localhost", 9999) mustEqual true
- connection.write("SLAVEOF localhost 9999\r\n") was called
- }
-
- "set a server as master if no params sent" in {
- connection.readBoolean returns true
- client.slaveOf() mustEqual true
- connection.write("SLAVEOF NO ONE\r\n") was called
- }
-
- "set a server as master" in {
- connection.readBoolean returns true
- client.setAsMaster mustEqual true
- connection.write("SLAVEOF NO ONE\r\n") was called
- }
-
- "select the current db" in {
- connection.readBoolean returns true
- client.selectDb(3) mustEqual true
- client.db mustEqual 3
- connection.write("SELECT 3\r\n") was called
- }
-
- "flush the db" in {
- connection.readBoolean returns true
- client.flushDb mustEqual true
- connection.write("FLUSHDB\r\n") was called
- }
-
- "flush all the dbs" in {
- connection.readBoolean returns true
- client.flushAll mustEqual true
- connection.write("FLUSHALL\r\n") was called
- }
-
- "shutdown the db" in {
- connection.readBoolean returns true
- client.shutdown mustEqual true
- connection.write("SHUTDOWN\r\n") was called
- }
-
- "move keys from one db to another" in {
- connection.readBoolean returns true
- client.move("a", 2) mustEqual true
- connection.write("MOVE a 2\r\n") was called
- }
-
- "quit" in {
- connection.disconnect returns true
- client.quit mustEqual true
- connection.write("QUIT\r\n") was called
- connection.disconnect was called
- }
-
- "auth with the server" in {
- connection.readBoolean returns true
- client.auth("secret") mustEqual true
- connection.write("AUTH secret\r\n") was called
- }
- }
-}
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/OperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/OperationsSpec.scala
deleted file mode 100644
index 7fe26be3d..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/OperationsSpec.scala
+++ /dev/null
@@ -1,105 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-
-object OperationsSpec extends Specification with Mockito {
-
- "Redis Client Operations" should {
-
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "set a key" in {
- connection.readBoolean returns true
- client.set("a", "b") mustEqual true
- connection.write("SET a 1\r\nb\r\n") was called
- }
-
- "set a key with setKey" in {
- connection.readBoolean returns true
- client.setKey("a", "b") mustEqual true
- connection.write("SET a 1\r\nb\r\n") was called
- }
-
- "set a key with expiration" in {
- connection.readBoolean returns true
- client.set("a", "b", 4) mustEqual true
- connection.write("SET a 1\r\nb\r\n") was called
- connection.write("EXPIRE a 4\r\n") was called
- }
-
- "expire a key" in {
- connection.readBoolean returns true
- client.expire("a", 4) mustEqual true
- connection.write("EXPIRE a 4\r\n") was called
- }
-
- "get a key" in {
- connection.readResponse returns "b"
- client.get("a") mustEqual "b"
- connection.write("GET a\r\n") was called
- }
-
- "get and set a key" in {
- connection.readResponse returns "old"
- client.getSet("a", "new") mustEqual "old"
- connection.write("GETSET a 3\r\nnew\r\n") was called
- }
-
- "delete a key" in {
- connection.readBoolean returns true
- client.delete("a") mustEqual true
- connection.write("DEL a\r\n") was called
- }
-
- "tell if a key exists" in {
- connection.readBoolean returns true
- client.exists("a") mustEqual true
- connection.write("EXISTS a\r\n") was called
- }
-
- "tell if a key exists" in {
- connection.readBoolean returns true
- client.exists("a") mustEqual true
- connection.write("EXISTS a\r\n") was called
- }
-
- "increment a value" in {
- connection.readInt returns 1
- client.incr("a") mustEqual 1
- connection.write("INCR a\r\n") was called
- }
-
- "increment a value by N" in {
- connection.readInt returns 27
- client.incr("a", 23) mustEqual 27
- connection.write("INCRBY a 23\r\n") was called
- }
-
- "decrement a value" in {
- connection.readInt returns 0
- client.decr("a") mustEqual 0
- connection.write("DECR a\r\n") was called
- }
-
- "decrement a value by N" in {
- connection.readInt returns 25
- client.decr("a", 2) mustEqual 25
- connection.write("DECRBY a 2\r\n") was called
- }
-
- "return type of key" in {
- connection.readResponse returns "String"
- client.getType("a") mustEqual "String"
- connection.write("TYPE a\r\n") was called
- }
- }
-}
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/SetOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/SetOperationsSpec.scala
deleted file mode 100644
index 78e6a5f2c..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/SetOperationsSpec.scala
+++ /dev/null
@@ -1,102 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-import org.mockito.Mockito.doNothing
-
-object SetOperationsSpec extends Specification with Mockito {
-
- "Redis Client Set Operations" should {
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "add a member to a set" in {
- connection.readBoolean returns true
- client.setAdd("set", "value") must beTrue
- connection.write("SADD set 5\r\nvalue\r\n") was called
- }
-
- "remove an member from a set" in {
- connection.readBoolean returns true
- client.setDelete("set", "value") must beTrue
- connection.write("SREM set 5\r\nvalue\r\n") was called
- }
-
- "return the number of elements in the set" in {
- connection.readInt returns 5
- client.setCount("set") mustEqual 5
- connection.write("SCARD set\r\n") was called
- }
-
- "return all the members from a set" in {
- val setResult = Set("one", "two", "three")
- connection.readSet returns setResult
- client.setMembers("set") mustEqual setResult
- connection.write("SMEMBERS set\r\n") was called
- }
-
- "pop an element from the set" in {
- connection.readString returns "one"
- client.setPop("set") mustEqual "one"
- connection.write("SPOP set\r\n") was called
- }
-
- "move an element from one set to another" in {
- connection.readBoolean returns true
- client.setMove("set", "toset", "value") mustEqual true
- connection.write("SMOVE set toset value\r\n") was called
- }
-
- "tell if member exists on the set" in {
- connection.readBoolean returns true
- client.setMemberExists("set", "value") mustEqual true
- connection.write("SISMEMBER set 5\r\nvalue\r\n") was called
- }
-
- "return the intersection between N sets" in {
- val setResult = Set("one", "two", "three")
- connection.readSet returns setResult
- client.setIntersect("set", "otherset", "another") mustEqual setResult
- connection.write("SINTER set otherset another\r\n") was called
- }
-
- "return the intersection between N sets and store it a new one" in {
- connection.readBoolean returns true
- client.setInterStore("set", "oneset", "twoset") mustEqual true
- connection.write("SINTERSTORE set oneset twoset\r\n") was called
- }
-
- "return the difference between N sets" in {
- val setResult = Set("one", "two", "three")
- connection.readSet returns setResult
- client.setDiff("set", "oneset", "twoset") mustEqual setResult
- connection.write("SDIFF set oneset twoset\r\n") was called
- }
-
- "return the difference between N sets and store it in a new one" in {
- connection.readBoolean returns true
- client.setDiffStore("newset", "oneset", "twoset") mustEqual true
- connection.write("SDIFFSTORE newset oneset twoset\r\n") was called
- }
-
- "return the union between N sets" in {
- val setResult = Set("one", "two", "three")
- connection.readSet returns setResult
- client.setUnion("set", "oneset", "twoset") mustEqual setResult
- connection.write("SUNION set oneset twoset\r\n") was called
- }
-
- "return the union between N sets and store it in a new one" in {
- connection.readBoolean returns true
- client.setUnionStore("set", "oneset", "twoset") mustEqual true
- connection.write("SUNIONSTORE set oneset twoset\r\n") was called
- }
- }
-}
\ No newline at end of file
diff --git a/client-libraries/scala/src/test/scala/com/redis/operations/SortOperationsSpec.scala b/client-libraries/scala/src/test/scala/com/redis/operations/SortOperationsSpec.scala
deleted file mode 100644
index 95f3c91dd..000000000
--- a/client-libraries/scala/src/test/scala/com/redis/operations/SortOperationsSpec.scala
+++ /dev/null
@@ -1,34 +0,0 @@
-import org.specs._
-import com.redis._
-
-import org.specs.mock.Mockito
-import org.mockito.Mock._
-import org.mockito.Mockito._
-
-object SortOperationsSpec extends Specification with Mockito {
-
- "Redis Client Sort Operations" should {
-
- var client: RedisTestClient = null
- var connection: Connection = null
-
- doBefore{
- connection = mock[Connection]
- client = new RedisTestClient(connection)
- }
-
- "sort the contents of the specified key" in {
- val listResult: List[String] = List("one", "two", "three")
- connection.readList returns listResult
- client.sort("set", "ALPHA DESC") mustEqual listResult
- connection.write("SORT set ALPHA DESC\r\n") was called
- }
-
- "sort the contents of the specified key with default" in {
- val listResult: List[String] = List("one", "two", "three")
- connection.readList returns listResult
- client.sort("set") mustEqual listResult
- connection.write("SORT set\r\n") was called
- }
- }
-}
diff --git a/client-libraries/tcl/redis.tcl b/client-libraries/tcl/redis.tcl
deleted file mode 100644
index 61dae0c12..000000000
--- a/client-libraries/tcl/redis.tcl
+++ /dev/null
@@ -1,131 +0,0 @@
-# Tcl clinet library - used by test-redis.tcl script for now
-# Copyright (C) 2009 Salvatore Sanfilippo
-# Released under the BSD license like Redis itself
-#
-# Example usage:
-#
-# set r [redis 127.0.0.1 6379]
-# $r lpush mylist foo
-# $r lpush mylist bar
-# $r lrange mylist 0 -1
-# $r close
-
-package provide redis 0.1
-
-namespace eval redis {}
-set ::redis::id 0
-array set ::redis::fd {}
-array set ::redis::bulkarg {}
-array set ::redis::multibulkarg {}
-
-# Flag commands requiring last argument as a bulk write operation
-foreach redis_bulk_cmd {
- set setnx rpush lpush lset lrem sadd srem sismember echo getset smove zadd zrem zscore
-} {
- set ::redis::bulkarg($redis_bulk_cmd) {}
-}
-
-# Flag commands requiring last argument as a bulk write operation
-foreach redis_multibulk_cmd {
- mset msetnx
-} {
- set ::redis::multibulkarg($redis_multibulk_cmd) {}
-}
-
-unset redis_bulk_cmd
-unset redis_multibulk_cmd
-
-proc redis {{server 127.0.0.1} {port 6379}} {
- set fd [socket $server $port]
- fconfigure $fd -translation binary
- set id [incr ::redis::id]
- set ::redis::fd($id) $fd
- interp alias {} ::redis::redisHandle$id {} ::redis::__dispatch__ $id
-}
-
-proc ::redis::__dispatch__ {id method args} {
- set fd $::redis::fd($id)
- if {[info command ::redis::__method__$method] eq {}} {
- if {[info exists ::redis::bulkarg($method)]} {
- set cmd "$method "
- append cmd [join [lrange $args 0 end-1]]
- append cmd " [string length [lindex $args end]]\r\n"
- append cmd [lindex $args end]
- ::redis::redis_writenl $fd $cmd
- } elseif {[info exists ::redis::multibulkarg($method)]} {
- set cmd "*[expr {[llength $args]+1}]\r\n"
- append cmd "$[string length $method]\r\n$method\r\n"
- foreach a $args {
- append cmd "$[string length $a]\r\n$a\r\n"
- }
- ::redis::redis_write $fd $cmd
- flush $fd
- } else {
- set cmd "$method "
- append cmd [join $args]
- ::redis::redis_writenl $fd $cmd
- }
- ::redis::redis_read_reply $fd
- } else {
- uplevel 1 [list ::redis::__method__$method $id $fd] $args
- }
-}
-
-proc ::redis::__method__close {id fd} {
- catch {close $fd}
- catch {unset ::redis::fd($id)}
- catch {interp alias {} ::redis::redisHandle$id {}}
-}
-
-proc ::redis::__method__channel {id fd} {
- return $fd
-}
-
-proc ::redis::redis_write {fd buf} {
- puts -nonewline $fd $buf
-}
-
-proc ::redis::redis_writenl {fd buf} {
- redis_write $fd $buf
- redis_write $fd "\r\n"
- flush $fd
-}
-
-proc ::redis::redis_readnl {fd len} {
- set buf [read $fd $len]
- read $fd 2 ; # discard CR LF
- return $buf
-}
-
-proc ::redis::redis_bulk_read {fd} {
- set count [redis_read_line $fd]
- if {$count == -1} return {}
- set buf [redis_readnl $fd $count]
- return $buf
-}
-
-proc ::redis::redis_multi_bulk_read fd {
- set count [redis_read_line $fd]
- if {$count == -1} return {}
- set l {}
- for {set i 0} {$i < $count} {incr i} {
- lappend l [redis_read_reply $fd]
- }
- return $l
-}
-
-proc ::redis::redis_read_line fd {
- string trim [gets $fd]
-}
-
-proc ::redis::redis_read_reply fd {
- set type [read $fd 1]
- switch -exact -- $type {
- : -
- + {redis_read_line $fd}
- - {return -code error [redis_read_line $fd]}
- $ {redis_bulk_read $fd}
- * {redis_multi_bulk_read $fd}
- default {return -code error "Bad protocol, $type as reply type byte"}
- }
-}
diff --git a/client-libraries/update-clojure-client.sh b/client-libraries/update-clojure-client.sh
deleted file mode 100755
index 125ad2caa..000000000
--- a/client-libraries/update-clojure-client.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/ragnard/redis-clojure.git
-cd redis-clojure
-rm -rf .git
-cd ..
-cd ..
-rm -rf clojure
-mv temp/redis-clojure clojure
-rm -rf temp
diff --git a/client-libraries/update-cpp-client.sh b/client-libraries/update-cpp-client.sh
deleted file mode 100755
index 87236f6ac..000000000
--- a/client-libraries/update-cpp-client.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/fictorial/redis-cpp-client.git
-cd redis-cpp-client
-rm -rf .git
-cd ..
-cd ..
-rm -rf cpp
-mv temp/redis-cpp-client cpp
-rm -rf temp
diff --git a/client-libraries/update-erlang-client.sh b/client-libraries/update-erlang-client.sh
deleted file mode 100755
index 9d05c0cf1..000000000
--- a/client-libraries/update-erlang-client.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "Sorry for now this must be done by hand... don't know mercurial enough"
diff --git a/client-libraries/update-lua-client.sh b/client-libraries/update-lua-client.sh
deleted file mode 100755
index 1843997f2..000000000
--- a/client-libraries/update-lua-client.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/nrk/redis-lua.git
-cd redis-lua
-rm -rf .git
-cd ..
-cd ..
-rm -rf lua
-mv temp/redis-lua lua
-rm -rf temp
diff --git a/client-libraries/update-perl-client.sh b/client-libraries/update-perl-client.sh
deleted file mode 100755
index 164b40dcf..000000000
--- a/client-libraries/update-perl-client.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-svn checkout svn://svn.rot13.org/Redis/
-find . -name '.svn' -exec rm -rf {} \; 2> /dev/null
-cd ..
-rm -rf perl
-mv temp/Redis perl
-rm -rf temp
diff --git a/client-libraries/update-python-client.sh b/client-libraries/update-python-client.sh
deleted file mode 100755
index e5f03833d..000000000
--- a/client-libraries/update-python-client.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/ludoo/redis.git
-cd ..
-rm -rf python
-mv temp/redis/client-libraries/python python
-rm -rf temp
diff --git a/client-libraries/update-ruby-client.sh b/client-libraries/update-ruby-client.sh
deleted file mode 100755
index 56cfab517..000000000
--- a/client-libraries/update-ruby-client.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/ezmobius/redis-rb.git
-#git clone git://github.com/jodosha/redis-rb.git
-cd redis-rb
-rm -rf .git
-cd ..
-cd ..
-rm -rf ruby
-mv temp/redis-rb ruby
-rm -rf temp
diff --git a/client-libraries/update-scala-client.sh b/client-libraries/update-scala-client.sh
deleted file mode 100755
index 622097b8c..000000000
--- a/client-libraries/update-scala-client.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh
-rm -rf temp
-mkdir temp
-cd temp
-git clone git://github.com/acrosa/scala-redis.git
-cd scala-redis
-rm -rf .git
-cd ..
-cd ..
-rm -rf scala
-mv temp/scala-redis scala
-rm -rf temp