hiredis 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -47
- data/ext/hiredis_ext/connection.c +104 -35
- data/ext/hiredis_ext/extconf.rb +1 -1
- data/ext/hiredis_ext/hiredis_ext.c +4 -2
- data/ext/hiredis_ext/hiredis_ext.h +0 -1
- data/ext/hiredis_ext/reader.c +0 -20
- data/lib/hiredis.rb +2 -10
- data/lib/hiredis/connection.rb +7 -14
- data/lib/hiredis/ext/connection.rb +16 -0
- data/lib/hiredis/ext/reader.rb +2 -0
- data/lib/hiredis/reader.rb +10 -1
- data/lib/hiredis/ruby/connection.rb +113 -0
- data/lib/hiredis/ruby/reader.rb +164 -0
- data/lib/hiredis/version.rb +1 -1
- data/vendor/hiredis/Makefile +4 -5
- data/vendor/hiredis/async.c +2 -0
- data/vendor/hiredis/async.h +3 -3
- data/vendor/hiredis/dict.c +27 -77
- data/vendor/hiredis/dict.h +12 -16
- data/vendor/hiredis/hiredis.c +26 -17
- data/vendor/hiredis/hiredis.h +4 -2
- data/vendor/hiredis/net.c +85 -18
- data/vendor/hiredis/net.h +2 -2
- data/vendor/hiredis/sds.c +129 -4
- data/vendor/hiredis/sds.h +2 -1
- data/vendor/hiredis/test.c +14 -5
- metadata +15 -29
- data/lib/hiredis/em.rb +0 -1
- data/lib/hiredis/em/base.rb +0 -36
- data/lib/hiredis/em/connection.rb +0 -25
data/vendor/hiredis/sds.h
CHANGED
@@ -44,11 +44,12 @@ struct sdshdr {
|
|
44
44
|
|
45
45
|
sds sdsnewlen(const void *init, size_t initlen);
|
46
46
|
sds sdsnew(const char *init);
|
47
|
-
sds sdsempty();
|
47
|
+
sds sdsempty(void);
|
48
48
|
size_t sdslen(const sds s);
|
49
49
|
sds sdsdup(const sds s);
|
50
50
|
void sdsfree(sds s);
|
51
51
|
size_t sdsavail(sds s);
|
52
|
+
sds sdsgrowzero(sds s, size_t len);
|
52
53
|
sds sdscatlen(sds s, const void *t, size_t len);
|
53
54
|
sds sdscat(sds s, const char *t);
|
54
55
|
sds sdscpylen(sds s, char *t, size_t len);
|
data/vendor/hiredis/test.c
CHANGED
@@ -32,7 +32,7 @@ static void __connect(redisContext **target) {
|
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
35
|
-
static void test_format_commands() {
|
35
|
+
static void test_format_commands(void) {
|
36
36
|
char *cmd;
|
37
37
|
int len;
|
38
38
|
|
@@ -116,7 +116,7 @@ static void test_format_commands() {
|
|
116
116
|
free(cmd);
|
117
117
|
}
|
118
118
|
|
119
|
-
static void test_blocking_connection() {
|
119
|
+
static void test_blocking_connection(void) {
|
120
120
|
redisContext *c;
|
121
121
|
redisReply *reply;
|
122
122
|
int major, minor;
|
@@ -261,7 +261,7 @@ static void test_blocking_connection() {
|
|
261
261
|
__connect(&c);
|
262
262
|
}
|
263
263
|
|
264
|
-
static void test_reply_reader() {
|
264
|
+
static void test_reply_reader(void) {
|
265
265
|
void *reader;
|
266
266
|
void *reply;
|
267
267
|
char *err;
|
@@ -318,9 +318,18 @@ static void test_reply_reader() {
|
|
318
318
|
ret = redisReplyReaderGetReply(reader,&reply);
|
319
319
|
test_cond(ret == REDIS_OK && reply == (void*)REDIS_REPLY_STATUS);
|
320
320
|
redisReplyReaderFree(reader);
|
321
|
+
|
322
|
+
test("Properly reset state after protocol error: ");
|
323
|
+
reader = redisReplyReaderCreate();
|
324
|
+
redisReplyReaderSetReplyObjectFunctions(reader,NULL);
|
325
|
+
redisReplyReaderFeed(reader,(char*)"x",1);
|
326
|
+
ret = redisReplyReaderGetReply(reader,&reply);
|
327
|
+
assert(ret == REDIS_ERR);
|
328
|
+
ret = redisReplyReaderGetReply(reader,&reply);
|
329
|
+
test_cond(ret == REDIS_OK && reply == NULL)
|
321
330
|
}
|
322
331
|
|
323
|
-
static void test_throughput() {
|
332
|
+
static void test_throughput(void) {
|
324
333
|
int i;
|
325
334
|
long long t1, t2;
|
326
335
|
redisContext *c = blocking_context;
|
@@ -354,7 +363,7 @@ static void test_throughput() {
|
|
354
363
|
printf("\t(1000x LRANGE with 500 elements: %.2fs)\n", (t2-t1)/1000000.0);
|
355
364
|
}
|
356
365
|
|
357
|
-
static void cleanup() {
|
366
|
+
static void cleanup(void) {
|
358
367
|
redisContext *c = blocking_context;
|
359
368
|
redisReply *reply;
|
360
369
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hiredis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pieter Noordhuis
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-02-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -32,32 +32,17 @@ dependencies:
|
|
32
32
|
- 7
|
33
33
|
- 1
|
34
34
|
version: 0.7.1
|
35
|
-
type: :
|
35
|
+
type: :development
|
36
36
|
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: redis
|
39
|
-
prerelease: false
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 9
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 1
|
49
|
-
- 1
|
50
|
-
version: 2.1.1
|
51
|
-
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
37
|
description: Ruby extension that wraps Hiredis (blocking connection and reply parsing)
|
54
|
-
email:
|
38
|
+
email:
|
39
|
+
- pcnoordhuis@gmail.com
|
55
40
|
executables: []
|
56
41
|
|
57
42
|
extensions:
|
58
43
|
- ext/hiredis_ext/extconf.rb
|
59
|
-
extra_rdoc_files:
|
60
|
-
|
44
|
+
extra_rdoc_files: []
|
45
|
+
|
61
46
|
files:
|
62
47
|
- COPYING
|
63
48
|
- Rakefile
|
@@ -67,10 +52,11 @@ files:
|
|
67
52
|
- ext/hiredis_ext/reader.c
|
68
53
|
- ext/hiredis_ext/hiredis_ext.h
|
69
54
|
- lib/hiredis/connection.rb
|
70
|
-
- lib/hiredis/
|
71
|
-
- lib/hiredis/
|
72
|
-
- lib/hiredis/em.rb
|
55
|
+
- lib/hiredis/ext/connection.rb
|
56
|
+
- lib/hiredis/ext/reader.rb
|
73
57
|
- lib/hiredis/reader.rb
|
58
|
+
- lib/hiredis/ruby/connection.rb
|
59
|
+
- lib/hiredis/ruby/reader.rb
|
74
60
|
- lib/hiredis/version.rb
|
75
61
|
- lib/hiredis.rb
|
76
62
|
- vendor/hiredis/async.c
|
@@ -118,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
104
|
requirements: []
|
119
105
|
|
120
106
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.
|
107
|
+
rubygems_version: 1.5.0
|
122
108
|
signing_key:
|
123
109
|
specification_version: 3
|
124
110
|
summary: Ruby extension that wraps Hiredis (blocking connection and reply parsing)
|
data/lib/hiredis/em.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'hiredis/em/connection'
|
data/lib/hiredis/em/base.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'hiredis/reader'
|
2
|
-
|
3
|
-
module Hiredis
|
4
|
-
|
5
|
-
module EM
|
6
|
-
|
7
|
-
class Base < ::EM::Connection
|
8
|
-
|
9
|
-
CRLF = "\r\n".freeze
|
10
|
-
|
11
|
-
def initialize
|
12
|
-
super
|
13
|
-
@reader = Reader.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def receive_data(data)
|
17
|
-
@reader.feed(data)
|
18
|
-
while reply = @reader.gets
|
19
|
-
receive_reply(reply)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def receive_reply(reply)
|
24
|
-
end
|
25
|
-
|
26
|
-
def send_command(*args)
|
27
|
-
args = args.flatten
|
28
|
-
send_data("*" + args.size.to_s + CRLF)
|
29
|
-
args.each do |arg|
|
30
|
-
arg = arg.to_s
|
31
|
-
send_data("$" + arg.size.to_s + CRLF + arg + CRLF)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'hiredis/em/base'
|
2
|
-
|
3
|
-
module Hiredis
|
4
|
-
|
5
|
-
module EM
|
6
|
-
|
7
|
-
class Connection < Base
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
super
|
11
|
-
@callbacks = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def receive_reply(reply)
|
15
|
-
callback = @callbacks.shift
|
16
|
-
callback.call(reply) if callback
|
17
|
-
end
|
18
|
-
|
19
|
-
def method_missing(sym, *args, &callback)
|
20
|
-
send_command(sym, *args)
|
21
|
-
@callbacks.push callback
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|