Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
67d3e950
Commit
67d3e950
authored
May 30, 2009
by
antirez
Browse files
Erlang client updated
parent
be424283
Changes
6
Show whitespace changes
Inline
Side-by-side
client-libraries/erlang/.hg_archival.txt
View file @
67d3e950
repo: 9e1f35ed7fdc7b3da7f5ff66a71d1975b85e2ae5
repo: 9e1f35ed7fdc7b3da7f5ff66a71d1975b85e2ae5
node:
d9dd3d00c6fafaa09809061816f4e3b85a32811d
node:
85e28ca5597e22ff1dde18ed4625f41923128993
client-libraries/erlang/src/client.erl
View file @
67d3e950
...
@@ -48,15 +48,18 @@ connect(Host) ->
...
@@ -48,15 +48,18 @@ connect(Host) ->
connect
(
Host
,
Port
)
->
connect
(
Host
,
Port
)
->
gen_server
:
start_link
(
?
MODULE
,
[
Host
,
Port
],
[]).
gen_server
:
start_link
(
?
MODULE
,
[
Host
,
Port
],
[]).
% This is the simple send with a single row of commands
ssend
(
Client
,
Cmd
)
->
ssend
(
Client
,
Cmd
,
[]).
ssend
(
Client
,
Cmd
)
->
ssend
(
Client
,
Cmd
,
[]).
ssend
(
Client
,
Cmd
,
Args
)
->
ssend
(
Client
,
Cmd
,
Args
)
->
gen_server
:
cast
(
Client
,
{
send
,
sformat
([
Cmd
|
Args
])}).
gen_server
:
cast
(
Client
,
{
send
,
sformat
([
Cmd
|
Args
])}).
% This is the complete send with multiple rows
send
(
Client
,
Cmd
)
->
send
(
Client
,
Cmd
,
[]).
send
(
Client
,
Cmd
)
->
send
(
Client
,
Cmd
,
[]).
send
(
Client
,
Cmd
,
Args
)
->
send
(
Client
,
Cmd
,
Args
)
->
gen_server
:
cast
(
Client
,
{
send
,
gen_server
:
cast
(
Client
,
{
send
,
string
:
join
([
str
(
Cmd
),
format
(
Args
)],
" "
)}).
string
:
join
([
str
(
Cmd
),
format
(
Args
)],
" "
)}).
% asynchronous send, we don't care about the result.
asend
(
Client
,
Cmd
)
->
asend
(
Client
,
Cmd
)
->
gen_server
:
cast
(
Client
,
{
asend
,
Cmd
}).
gen_server
:
cast
(
Client
,
{
asend
,
Cmd
}).
disconnect
(
Client
)
->
disconnect
(
Client
)
->
...
...
client-libraries/erlang/src/erldis.erl
View file @
67d3e950
...
@@ -24,14 +24,19 @@ internal_set_like(Client, Command, Key, Value) ->
...
@@ -24,14 +24,19 @@ internal_set_like(Client, Command, Key, Value) ->
get_all_results
(
Client
)
->
client
:
get_all_results
(
Client
).
get_all_results
(
Client
)
->
client
:
get_all_results
(
Client
).
auth
(
Client
,
Password
)
->
client
:
ssend
(
Client
,
auth
,
[
Password
]).
set
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
set
,
Key
,
Value
).
set
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
set
,
Key
,
Value
).
get
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
get
,
[
Key
]).
getset
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
getset
,
Key
,
Value
).
mget
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
mget
,
Keys
).
setnx
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
setnx
,
Key
,
Value
).
setnx
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
setnx
,
Key
,
Value
).
incr
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
incr
,
[
Key
]).
incr
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
incr
,
[
Key
]).
incrby
(
Client
,
Key
,
By
)
->
client
:
ssend
(
Client
,
incrby
,
[
Key
,
By
]).
incrby
(
Client
,
Key
,
By
)
->
client
:
ssend
(
Client
,
incrby
,
[
Key
,
By
]).
decr
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
decr
,
[
Key
]).
decr
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
decr
,
[
Key
]).
decrby
(
Client
,
Key
,
By
)
->
client
:
ssend
(
Client
,
decrby
,
[
Key
,
By
]).
decrby
(
Client
,
Key
,
By
)
->
client
:
ssend
(
Client
,
decrby
,
[
Key
,
By
]).
get
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
get
,
[
Key
]).
mget
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
mget
,
Keys
).
%% Commands operating on every value
%% Commands operating on every value
exists
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
exists
,
[
Key
]).
exists
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
exists
,
[
Key
]).
...
@@ -41,10 +46,11 @@ keys(Client, Pattern) -> client:ssend(Client, keys, [Pattern]).
...
@@ -41,10 +46,11 @@ keys(Client, Pattern) -> client:ssend(Client, keys, [Pattern]).
randomkey
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
randomkey
,
[
Key
]).
randomkey
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
randomkey
,
[
Key
]).
rename
(
Client
,
OldKey
,
NewKey
)
->
client
:
ssend
(
Client
,
rename
,
[
OldKey
,
NewKey
]).
rename
(
Client
,
OldKey
,
NewKey
)
->
client
:
ssend
(
Client
,
rename
,
[
OldKey
,
NewKey
]).
renamenx
(
Client
,
OldKey
,
NewKey
)
->
client
:
ssend
(
Client
,
renamenx
,
[
OldKey
,
NewKey
]).
renamenx
(
Client
,
OldKey
,
NewKey
)
->
client
:
ssend
(
Client
,
renamenx
,
[
OldKey
,
NewKey
]).
dbsize
(
Client
)
->
client
:
ssend
(
Client
,
dbsize
).
expire
(
Client
,
Key
,
Seconds
)
->
client
:
ssend
(
Client
,
expire
,
[
Key
,
Seconds
]).
ttl
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
ttl
,
[
Key
]).
%% Commands operating on both lists and sets
sort
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
sort
,
[
Key
]).
sort
(
Client
,
Key
,
Extra
)
->
client
:
ssend
(
Client
,
sort
,
[
Key
,
Extra
]).
%% Commands operating on lists
%% Commands operating on lists
rpush
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
rpush
,
Key
,
Value
).
rpush
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
rpush
,
Key
,
Value
).
...
@@ -53,30 +59,54 @@ llen(Client, Key) -> client:ssend(Client, llen, [Key]).
...
@@ -53,30 +59,54 @@ llen(Client, Key) -> client:ssend(Client, llen, [Key]).
lrange
(
Client
,
Key
,
Start
,
End
)
->
client
:
ssend
(
Client
,
lrange
,
[
Key
,
Start
,
End
]).
lrange
(
Client
,
Key
,
Start
,
End
)
->
client
:
ssend
(
Client
,
lrange
,
[
Key
,
Start
,
End
]).
ltrim
(
Client
,
Key
,
Start
,
End
)
->
client
:
ssend
(
Client
,
ltrim
,
[
Key
,
Start
,
End
]).
ltrim
(
Client
,
Key
,
Start
,
End
)
->
client
:
ssend
(
Client
,
ltrim
,
[
Key
,
Start
,
End
]).
lindex
(
Client
,
Key
,
Index
)
->
client
:
ssend
(
Client
,
lindex
,
[
Key
,
Index
]).
lindex
(
Client
,
Key
,
Index
)
->
client
:
ssend
(
Client
,
lindex
,
[
Key
,
Index
]).
lpop
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
lpop
,
[
Key
]).
rpop
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
rpop
,
[
Key
]).
lrem
(
Client
,
Key
,
Number
,
Value
)
->
client
:
send
(
Client
,
lrem
,
[[
Key
,
Number
,
length
(
Value
)],
[
Value
]]).
lset
(
Client
,
Key
,
Index
,
Value
)
->
lset
(
Client
,
Key
,
Index
,
Value
)
->
client
:
send
(
Client
,
lset
,
[[
Key
,
Index
,
length
(
Value
)],
client
:
send
(
Client
,
lset
,
[[
Key
,
Index
,
length
(
Value
)],
[
Value
]]).
[
Value
]]).
lrem
(
Client
,
Key
,
Number
,
Value
)
->
client
:
send
(
Client
,
lrem
,
[[
Key
,
Number
,
length
(
Value
)],
[
Value
]]).
lpop
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
lpop
,
[
Key
]).
rpop
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
rpop
,
[
Key
]).
%% Commands operating on sets
%% Commands operating on sets
sadd
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
sadd
,
Key
,
Value
).
sadd
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
sadd
,
Key
,
Value
).
srem
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
srem
,
Key
,
Value
).
srem
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
srem
,
Key
,
Value
).
smove
(
Client
,
SrcKey
,
DstKey
,
Member
)
->
client
:
send
(
Client
,
smove
,
[[
SrcKey
,
DstKey
,
length
(
Member
)],
[
Member
]]).
scard
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
scard
,
[
Key
]).
scard
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
scard
,
[
Key
]).
sismember
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
sismember
,
Key
,
Value
).
sismember
(
Client
,
Key
,
Value
)
->
internal_set_like
(
Client
,
sismember
,
Key
,
Value
).
sintersect
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
sinter
,
Keys
).
sintersect
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
sinter
,
Keys
).
sinter
(
Client
,
Keys
)
->
sintersect
(
Client
,
Keys
).
sinterstore
(
Client
,
DstKey
,
Keys
)
->
client
:
ssend
(
Client
,
sinterstore
,
[
DstKey
|
Keys
]).
sunion
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
sunion
,
Keys
).
sunionstore
(
Client
,
DstKey
,
Keys
)
->
client
:
ssend
(
Client
,
sunionstore
,
[
DstKey
|
Keys
]).
sdiff
(
Client
,
Keys
)
->
client
:
ssend
(
Client
,
sdiff
,
Keys
).
sdiffstore
(
Client
,
DstKey
,
Keys
)
->
client
:
ssend
(
Client
,
sdiffstore
,
[
DstKey
|
Keys
]).
smembers
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
smembers
,
[
Key
]).
smembers
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
smembers
,
[
Key
]).
%% Multiple DB commands
%% Multiple DB commands
flushdb
(
Client
)
->
client
:
ssend
(
Client
,
flushdb
).
flushall
(
Client
)
->
client
:
ssend
(
Client
,
flushall
).
select
(
Client
,
Index
)
->
client
:
ssend
(
Client
,
select
,
[
Index
]).
select
(
Client
,
Index
)
->
client
:
ssend
(
Client
,
select
,
[
Index
]).
move
(
Client
,
Key
,
DBIndex
)
->
client
:
ssend
(
Client
,
move
,
[
Key
,
DBIndex
]).
move
(
Client
,
Key
,
DBIndex
)
->
client
:
ssend
(
Client
,
move
,
[
Key
,
DBIndex
]).
flushdb
(
Client
)
->
client
:
ssend
(
Client
,
flushdb
).
flushall
(
Client
)
->
client
:
ssend
(
Client
,
flushall
).
%% Commands operating on both lists and sets
sort
(
Client
,
Key
)
->
client
:
ssend
(
Client
,
sort
,
[
Key
]).
sort
(
Client
,
Key
,
Extra
)
->
client
:
ssend
(
Client
,
sort
,
[
Key
,
Extra
]).
%% Persistence control commands
save
(
Client
)
->
client
:
ssend
(
Client
,
save
).
save
(
Client
)
->
client
:
ssend
(
Client
,
save
).
bgsave
(
Client
)
->
client
:
ssend
(
Client
,
bgsave
).
bgsave
(
Client
)
->
client
:
ssend
(
Client
,
bgsave
).
lastsave
(
Client
)
->
client
:
ssend
(
Client
,
lastsave
).
lastsave
(
Client
)
->
client
:
ssend
(
Client
,
lastsave
).
shutdown
(
Client
)
->
client
:
asend
(
Client
,
shutdown
).
shutdown
(
Client
)
->
client
:
asend
(
Client
,
shutdown
).
%% Remote server control commands
info
(
Client
)
->
client
:
ssend
(
Client
,
info
).
slaveof
(
Client
,
Host
,
Port
)
->
client
:
ssend
(
Client
,
slaveof
,
[
Host
,
Port
]).
slaveof
(
Client
)
->
client
:
ssend
(
Client
,
slaveof
,
[
"no one"
]).
client-libraries/erlang/test/erldis_tests.erl
View file @
67d3e950
...
@@ -14,7 +14,7 @@ utils_test() ->
...
@@ -14,7 +14,7 @@ utils_test() ->
?
assertEqual
(
client
:
format
([[
1
,
2
,
3
]]),
"1 2 3"
),
?
assertEqual
(
client
:
format
([[
1
,
2
,
3
]]),
"1 2 3"
),
?
assertEqual
(
client
:
format
([[
1
,
2
,
3
],
[
4
,
5
,
6
]]),
"1 2 3
\r\n
4 5 6"
).
?
assertEqual
(
client
:
format
([[
1
,
2
,
3
],
[
4
,
5
,
6
]]),
"1 2 3
\r\n
4 5 6"
).
pipeline
_test
()
->
basic
_test
()
->
{
ok
,
Client
}
=
erldis
:
connect
(
"localhost"
),
{
ok
,
Client
}
=
erldis
:
connect
(
"localhost"
),
erldis
:
flushall
(
Client
),
erldis
:
flushall
(
Client
),
erldis
:
get
(
Client
,
"pippo"
),
erldis
:
get
(
Client
,
"pippo"
),
...
...
client-libraries/erlang/test/proto_tests.erl
View file @
67d3e950
...
@@ -7,4 +7,4 @@ parse_test() ->
...
@@ -7,4 +7,4 @@ parse_test() ->
pong
=
proto
:
parse
(
empty
,
"+PONG"
),
pong
=
proto
:
parse
(
empty
,
"+PONG"
),
false
=
proto
:
parse
(
empty
,
":0"
),
false
=
proto
:
parse
(
empty
,
":0"
),
true
=
proto
:
parse
(
empty
,
":1"
),
true
=
proto
:
parse
(
empty
,
":1"
),
{
error
,
no_such_key
}
=
proto
:
parse
(
empty
,
"-1"
).
{
error
,
"1"
}
=
proto
:
parse
(
empty
,
"-1"
).
client-libraries/update-python-client.sh
0 → 100755
View file @
67d3e950
#!/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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment