em-hiredis 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +19 -0
- data/README.md +80 -27
- data/examples/getting_started.rb +14 -0
- data/examples/pubsub_basics.rb +24 -0
- data/examples/pubsub_more.rb +51 -0
- data/examples/pubsub_raw.rb +25 -0
- data/lib/em-hiredis.rb +23 -3
- data/lib/em-hiredis/base_client.rb +200 -0
- data/lib/em-hiredis/client.rb +40 -155
- data/lib/em-hiredis/connection.rb +12 -4
- data/lib/em-hiredis/lock.rb +106 -0
- data/lib/em-hiredis/persistent_lock.rb +77 -0
- data/lib/em-hiredis/pubsub_client.rb +187 -0
- data/lib/em-hiredis/version.rb +1 -1
- data/spec/base_client_spec.rb +116 -0
- data/spec/connection_spec.rb +1 -1
- data/spec/live_redis_protocol_spec.rb +1 -1
- data/spec/pubsub_spec.rb +314 -0
- data/spec/redis_commands_spec.rb +29 -8
- data/spec/spec_helper.rb +3 -0
- data/spec/support/connection_helper.rb +5 -3
- data/spec/url_param_spec.rb +3 -3
- metadata +45 -22
data/spec/redis_commands_spec.rb
CHANGED
@@ -611,7 +611,7 @@ describe EventMachine::Hiredis, "commands" do
|
|
611
611
|
it "provides info (INFO)" do
|
612
612
|
connect do |redis|
|
613
613
|
redis.info do |r|
|
614
|
-
[:
|
614
|
+
[:redis_version, :total_connections_received, :connected_clients, :total_commands_processed, :connected_slaves, :uptime_in_seconds, :used_memory, :uptime_in_days].each do |x|
|
615
615
|
r.keys.include?(x).should == true
|
616
616
|
end
|
617
617
|
done
|
@@ -619,6 +619,17 @@ describe EventMachine::Hiredis, "commands" do
|
|
619
619
|
end
|
620
620
|
end
|
621
621
|
|
622
|
+
it "provides commandstats (INFO COMMANDSTATS)" do
|
623
|
+
connect do |redis|
|
624
|
+
redis.info_commandstats do |r|
|
625
|
+
r[:get][:calls].should be_a_kind_of(Integer)
|
626
|
+
r[:get][:usec].should be_a_kind_of(Integer)
|
627
|
+
r[:get][:usec_per_call].should be_a_kind_of(Float)
|
628
|
+
done
|
629
|
+
end
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
622
633
|
it "flushes the database (FLUSHDB)" do
|
623
634
|
connect do |redis|
|
624
635
|
redis.set('key1', 'keyone')
|
@@ -632,7 +643,7 @@ describe EventMachine::Hiredis, "commands" do
|
|
632
643
|
it "SELECTs database" do
|
633
644
|
connect do |redis|
|
634
645
|
redis.set("foo", "bar") do |set_response|
|
635
|
-
redis.select("
|
646
|
+
redis.select("10") do |select_response|
|
636
647
|
redis.get("foo") do |get_response|
|
637
648
|
get_response.should == nil; done
|
638
649
|
end
|
@@ -810,8 +821,9 @@ describe EventMachine::Hiredis, "with nested multi-bulk response" do
|
|
810
821
|
redis.multi
|
811
822
|
redis.smembers "user:one:interests"
|
812
823
|
redis.smembers "user:two:interests"
|
813
|
-
redis.exec do |
|
814
|
-
|
824
|
+
redis.exec do |interests_one, interests_two|
|
825
|
+
interests_one.sort.should == ["first-interest", "second-interest"]
|
826
|
+
interests_two.should == ['third-interest']
|
815
827
|
end
|
816
828
|
redis.mget("user:one:id", "user:two:id") do |user_ids|
|
817
829
|
user_ids.should == ['id-one', 'id-two']
|
@@ -824,11 +836,20 @@ end
|
|
824
836
|
describe EventMachine::Hiredis, "monitor" do
|
825
837
|
it "returns monitored commands" do
|
826
838
|
connect do |redis|
|
827
|
-
|
828
|
-
|
829
|
-
|
839
|
+
# 1. Create 2nd connection to send traffic to monitor
|
840
|
+
redis2 = EventMachine::Hiredis.connect("redis://localhost:6379/")
|
841
|
+
redis2.callback {
|
842
|
+
# 2. Monitor after command has connected
|
843
|
+
redis.monitor do |reply|
|
844
|
+
reply.should == "OK"
|
845
|
+
|
846
|
+
# 3. Command which should show up in monitor output
|
847
|
+
redis2.get('foo')
|
848
|
+
end
|
849
|
+
}
|
850
|
+
|
830
851
|
redis.on(:monitor) do |line|
|
831
|
-
line.should =~ /
|
852
|
+
line.should =~ /foo/
|
832
853
|
done
|
833
854
|
end
|
834
855
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module ConnectionHelper
|
2
|
-
|
3
|
-
|
2
|
+
# Use db 9 for tests to avoid flushing the main db
|
3
|
+
# It would be nice if there was a standard db number for testing...
|
4
|
+
def connect(timeout = 1, url = "redis://localhost:6379/9", &blk)
|
5
|
+
em(timeout) do
|
4
6
|
redis = EventMachine::Hiredis.connect(url)
|
5
|
-
redis.
|
7
|
+
redis.flushdb
|
6
8
|
blk.call(redis)
|
7
9
|
end
|
8
10
|
end
|
data/spec/url_param_spec.rb
CHANGED
@@ -7,7 +7,7 @@ describe EventMachine::Hiredis, "URL parsing" do
|
|
7
7
|
|
8
8
|
redis.host.should == "127.0.0.1"
|
9
9
|
redis.port.should == 6379
|
10
|
-
redis.db.should ==
|
10
|
+
redis.db.should == 0
|
11
11
|
redis.password.should == nil
|
12
12
|
end
|
13
13
|
|
@@ -16,7 +16,7 @@ describe EventMachine::Hiredis, "URL parsing" do
|
|
16
16
|
|
17
17
|
redis.host.should == "foo.com"
|
18
18
|
redis.port.should == 999
|
19
|
-
redis.db.should ==
|
19
|
+
redis.db.should == 2
|
20
20
|
redis.password.should == "secr3t"
|
21
21
|
end
|
22
22
|
|
@@ -35,7 +35,7 @@ describe EventMachine::Hiredis, "URL parsing" do
|
|
35
35
|
|
36
36
|
redis.host.should == "foo.com"
|
37
37
|
redis.port.should == 999
|
38
|
-
redis.db.should ==
|
38
|
+
redis.db.should == 2
|
39
39
|
redis.password.should == "secr3t"
|
40
40
|
|
41
41
|
ENV.delete("REDIS_URL")
|
metadata
CHANGED
@@ -1,60 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-hiredis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Martyn Loughran
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: hiredis
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.4.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.4.0
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: em-spec
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ~>
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: 0.2.5
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.5
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
45
|
- - ~>
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: 2.6.0
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.6.0
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: rake
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :development
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
description: Eventmachine redis client using hiredis native parser
|
59
70
|
email:
|
60
71
|
- me@mloughran.com
|
@@ -64,18 +75,29 @@ extra_rdoc_files: []
|
|
64
75
|
files:
|
65
76
|
- .gitignore
|
66
77
|
- .rspec
|
78
|
+
- CHANGELOG.md
|
67
79
|
- Gemfile
|
68
80
|
- LICENCE
|
69
81
|
- README.md
|
70
82
|
- Rakefile
|
71
83
|
- em-hiredis.gemspec
|
84
|
+
- examples/getting_started.rb
|
85
|
+
- examples/pubsub_basics.rb
|
86
|
+
- examples/pubsub_more.rb
|
87
|
+
- examples/pubsub_raw.rb
|
72
88
|
- lib/em-hiredis.rb
|
89
|
+
- lib/em-hiredis/base_client.rb
|
73
90
|
- lib/em-hiredis/client.rb
|
74
91
|
- lib/em-hiredis/connection.rb
|
75
92
|
- lib/em-hiredis/event_emitter.rb
|
93
|
+
- lib/em-hiredis/lock.rb
|
94
|
+
- lib/em-hiredis/persistent_lock.rb
|
95
|
+
- lib/em-hiredis/pubsub_client.rb
|
76
96
|
- lib/em-hiredis/version.rb
|
97
|
+
- spec/base_client_spec.rb
|
77
98
|
- spec/connection_spec.rb
|
78
99
|
- spec/live_redis_protocol_spec.rb
|
100
|
+
- spec/pubsub_spec.rb
|
79
101
|
- spec/redis_commands_spec.rb
|
80
102
|
- spec/spec_helper.rb
|
81
103
|
- spec/support/connection_helper.rb
|
@@ -83,31 +105,32 @@ files:
|
|
83
105
|
- spec/url_param_spec.rb
|
84
106
|
homepage: http://github.com/mloughran/em-hiredis
|
85
107
|
licenses: []
|
108
|
+
metadata: {}
|
86
109
|
post_install_message:
|
87
110
|
rdoc_options: []
|
88
111
|
require_paths:
|
89
112
|
- lib
|
90
113
|
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
114
|
requirements:
|
93
|
-
- -
|
115
|
+
- - '>='
|
94
116
|
- !ruby/object:Gem::Version
|
95
117
|
version: '0'
|
96
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
119
|
requirements:
|
99
|
-
- -
|
120
|
+
- - '>='
|
100
121
|
- !ruby/object:Gem::Version
|
101
122
|
version: '0'
|
102
123
|
requirements: []
|
103
124
|
rubyforge_project: em-hiredis
|
104
|
-
rubygems_version:
|
125
|
+
rubygems_version: 2.0.0
|
105
126
|
signing_key:
|
106
|
-
specification_version:
|
127
|
+
specification_version: 4
|
107
128
|
summary: Eventmachine redis client
|
108
129
|
test_files:
|
130
|
+
- spec/base_client_spec.rb
|
109
131
|
- spec/connection_spec.rb
|
110
132
|
- spec/live_redis_protocol_spec.rb
|
133
|
+
- spec/pubsub_spec.rb
|
111
134
|
- spec/redis_commands_spec.rb
|
112
135
|
- spec/spec_helper.rb
|
113
136
|
- spec/support/connection_helper.rb
|