Commit 1259672f authored by antirez's avatar antirez
Browse files

client libs removed from Redis git

parent 5762b7f0
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
}
}
}
# 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"}
}
}
#!/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
#!/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
#!/bin/sh
echo "Sorry for now this must be done by hand... don't know mercurial enough"
#!/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
#!/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
#!/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
#!/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
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment