oria 0.0.3 → 0.1.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.
- data/.gitignore +1 -0
- data/README.markdown +20 -32
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/benchmarks/em_stop_v_disconnect.rb +34 -0
- data/benchmarks/eventmachine/client.rb +15 -0
- data/benchmarks/eventmachine/tcp_server.rb +12 -0
- data/benchmarks/eventmachine/udp_server.rb +12 -0
- data/benchmarks/hash_v_redis.rb +33 -0
- data/benchmarks/{sequel_v_oria.rb → mysql_v_oria.rb} +0 -0
- data/benchmarks/{mysql_table.sql → support/mysql_table.sql} +0 -0
- data/benchmarks/tcp_v_redis.rb +41 -0
- data/benchmarks/udp_v_redis.rb +42 -0
- data/bin/oria +28 -19
- data/lib/oria/client.rb +4 -1
- data/lib/oria/server.rb +36 -16
- data/lib/oria.rb +16 -18
- data/oria.gemspec +11 -4
- data/spec/oria_spec.rb +103 -106
- data/spec/spec_helper.rb +5 -0
- metadata +11 -4
data/.gitignore
CHANGED
data/README.markdown
CHANGED
@@ -144,46 +144,34 @@ Which means: **please report any problems you have using the [Github issue trac
|
|
144
144
|
Benchmarks
|
145
145
|
-
|
146
146
|
|
147
|
-
|
147
|
+
Want to find out how well Oria will perform compared to existing solutions? Here are a few benchmarks.
|
148
148
|
|
149
|
-
|
150
|
-
Redis (write): 0.050000 0.020000 0.070000 ( 0.115850)
|
151
|
-
Oria (write): 0.140000 0.110000 0.250000 ( 1.267912)
|
152
|
-
Redis (read): 0.070000 0.020000 0.090000 ( 0.145078)
|
153
|
-
Oria (read): 0.150000 0.110000 0.260000 ( 1.247791)
|
154
|
-
|
155
|
-
As you can see, Oria is about 10x slower than Redis on my development computer. Even worse, if you run the benchmark like so:
|
156
|
-
|
157
|
-
ruby redis_v_oria.rb 10000
|
158
|
-
|
159
|
-
Oria's server will fail to fulfill all of those requests. Scary. Clearly, it needs some serious improvement. Oria will never be
|
160
|
-
as performant as something like Redis - it's not meant to be (plus it's written in Ruby, not C). But it could use some reduction
|
161
|
-
in overhead, and any help is welcome.
|
162
|
-
|
163
|
-
But I knew Oria wouldn't compete with Redis. What about MySQL?
|
149
|
+
Here's Redis and Oria:
|
164
150
|
|
165
151
|
user system total real
|
166
|
-
|
167
|
-
Oria (write): 0.
|
168
|
-
|
169
|
-
Oria (read): 0.
|
152
|
+
Redis (write): 0.040000 0.020000 0.060000 ( 0.112147)
|
153
|
+
Oria (write): 0.130000 0.100000 0.230000 ( 0.394356)
|
154
|
+
Redis (read): 0.070000 0.020000 0.090000 ( 0.140881)
|
155
|
+
Oria (read): 0.130000 0.100000 0.230000 ( 0.394533)
|
156
|
+
|
157
|
+
Obviously, Redis is going to smack Oria down no matter what. Still, it's in a competitive range.
|
170
158
|
|
171
|
-
|
159
|
+
Here's MySQL and Oria:
|
172
160
|
|
173
161
|
user system total real
|
174
|
-
|
175
|
-
Oria (write): 0.
|
176
|
-
|
177
|
-
Oria (read): 0.
|
162
|
+
MySQL (write): 0.260000 0.030000 0.290000 ( 0.423971)
|
163
|
+
Oria (write): 0.140000 0.100000 0.240000 ( 0.406949)
|
164
|
+
MySQL (read): 0.310000 0.020000 0.330000 ( 0.468195)
|
165
|
+
Oria (read): 0.100000 0.100000 0.200000 ( 0.330884)
|
178
166
|
|
179
|
-
|
167
|
+
Oh snap! Oria outperforms MySQL. How about SQLite3, in memory?
|
180
168
|
|
181
|
-
|
182
|
-
|
183
|
-
Oria (write):
|
184
|
-
|
185
|
-
Oria (read):
|
169
|
+
user system total real
|
170
|
+
SQLite3 (write): 0.360000 0.010000 0.370000 ( 0.376660)
|
171
|
+
Oria (write): 0.100000 0.100000 0.200000 ( 0.368118)
|
172
|
+
SQLite3 (read): 0.370000 0.010000 0.380000 ( 0.379038)
|
173
|
+
Oria (read): 0.150000 0.100000 0.250000 ( 0.406342)
|
186
174
|
|
187
|
-
|
175
|
+
Looks like Oria will write faster but read slower than SQLite3 in-memory.
|
188
176
|
|
189
177
|
Copyright (c) 2009 Flip Sasser, released under the MIT license
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'eventmachine/client'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
class StopClient < EchoClient
|
7
|
+
def receive_data(data)
|
8
|
+
@response = data
|
9
|
+
EventMachine.stop_event_loop
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
client = nil
|
14
|
+
n = (ARGV.shift || 1000).to_i
|
15
|
+
|
16
|
+
Benchmark.bm(25) do |bm|
|
17
|
+
bm.report("EM (stop_event_loop):") do
|
18
|
+
n.times do
|
19
|
+
EventMachine.run do
|
20
|
+
client = EventMachine.connect "0.0.0.0", 8080, StopClient
|
21
|
+
client.send_data('PUT foo bar')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
bm.report("EM (close_connection):") do
|
27
|
+
n.times do
|
28
|
+
EventMachine.run do
|
29
|
+
client = EventMachine.connect "0.0.0.0", 8080, EchoClient
|
30
|
+
client.send_data('PUT foo bar')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'redis'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
redis = Redis.new
|
6
|
+
hash = Hash.new
|
7
|
+
n = (ARGV.shift || 1000).to_i
|
8
|
+
|
9
|
+
Benchmark.bm(15) do |bm|
|
10
|
+
bm.report("Redis (write):") do
|
11
|
+
n.times do
|
12
|
+
redis['foo'] = 'bar'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
bm.report("Hash (write):") do
|
17
|
+
n.times do
|
18
|
+
hash['foo'] = 'bar'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
bm.report("Redis (read):") do
|
23
|
+
n.times do
|
24
|
+
foo = redis['foo']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
bm.report("Hash (read):") do
|
29
|
+
n.times do
|
30
|
+
foo = hash['foo']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'redis'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'eventmachine/client'
|
5
|
+
require 'benchmark'
|
6
|
+
|
7
|
+
redis = Redis.new
|
8
|
+
client = nil
|
9
|
+
n = (ARGV.shift || 1000).to_i
|
10
|
+
|
11
|
+
Benchmark.bm(15) do |bm|
|
12
|
+
bm.report("Redis (write):") do
|
13
|
+
n.times do
|
14
|
+
redis['foo'] = 'bar'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
bm.report("Echo (write):") do
|
19
|
+
n.times do
|
20
|
+
EventMachine.run do
|
21
|
+
client = EventMachine.connect "0.0.0.0", 8080, EchoClient
|
22
|
+
client.send_data('PUT foo bar')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
bm.report("Redis (read):") do
|
28
|
+
n.times do
|
29
|
+
foo = redis['foo']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
bm.report("Echo (read):") do
|
34
|
+
n.times do
|
35
|
+
EventMachine.run do
|
36
|
+
client = EventMachine.connect "0.0.0.0", 8080, EchoClient
|
37
|
+
client.send_data('GET foo')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'redis'
|
3
|
+
require 'eventmachine'
|
4
|
+
require 'eventmachine/client'
|
5
|
+
require 'benchmark'
|
6
|
+
|
7
|
+
redis = Redis.new
|
8
|
+
client = nil
|
9
|
+
n = (ARGV.shift || 1000).to_i
|
10
|
+
|
11
|
+
Benchmark.bm(15) do |bm|
|
12
|
+
bm.report("Redis (write):") do
|
13
|
+
n.times do
|
14
|
+
redis['foo'] = 'bar'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
bm.report("Echo (write):") do
|
19
|
+
n.times do
|
20
|
+
EventMachine.run do
|
21
|
+
# TODO: Figure out how EM handles connecting TO UDP servers
|
22
|
+
client = EventMachine.open_datagram_socket "0.0.0.0", 0, EchoClient
|
23
|
+
client.send_datagram('GET foo', "0.0.0.0", 8080)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
bm.report("Redis (read):") do
|
29
|
+
n.times do
|
30
|
+
foo = redis['foo']
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
bm.report("Echo (read):") do
|
35
|
+
n.times do
|
36
|
+
EventMachine.run do
|
37
|
+
client = EventMachine.open_datagram_socket "0.0.0.0", 0, EchoClient
|
38
|
+
client.send_datagram('GET foo', "0.0.0.0", 8080)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/bin/oria
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'optparse'
|
3
3
|
require 'rubygems'
|
4
|
-
require 'oria'
|
5
|
-
|
4
|
+
# require 'oria'
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'oria'))
|
6
6
|
|
7
7
|
module OriaCommand
|
8
8
|
def self.go
|
@@ -13,6 +13,7 @@ module OriaCommand
|
|
13
13
|
stop
|
14
14
|
when 'restart'
|
15
15
|
stop
|
16
|
+
sleep 0.5
|
16
17
|
start
|
17
18
|
else
|
18
19
|
puts parser
|
@@ -27,40 +28,48 @@ module OriaCommand
|
|
27
28
|
@options[:port] = port
|
28
29
|
end
|
29
30
|
opts.on('-h', '--host [IP]', 'The hostname or IP Oria should listen on.') do |host|
|
30
|
-
@options[:host] =
|
31
|
+
@options[:host] = host
|
31
32
|
end
|
32
|
-
opts.on('-d', '--
|
33
|
-
@options[:
|
33
|
+
opts.on('-d', '--daemonize', 'Daemonize the Oria process') do |daemonize|
|
34
|
+
@options[:daemonize] = true
|
35
|
+
end
|
36
|
+
opts.on('-D', '--debug', 'Log output to /tmp/oria.log') do |debug|
|
37
|
+
@options[:debug] ||= true
|
34
38
|
end
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
42
|
def self.parse_options
|
39
|
-
@options = {:host => '0.0.0.0', :port =>
|
43
|
+
@options = {:host => '0.0.0.0', :port => Oria.port}
|
40
44
|
parser.parse!
|
41
45
|
end
|
42
46
|
|
43
47
|
def self.start
|
44
48
|
puts "Starting Oria..."
|
45
49
|
parse_options
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
start_server = lambda {
|
51
|
+
$0 = "oria #{@options[:host]}:#{@options[:port]}#{' -d' if @options[:daemonize]}"
|
52
|
+
Oria::Server.start(@options[:host], @options[:port], @options[:debug], :puts => !@options[:daemonize])
|
53
|
+
}
|
54
|
+
if @options[:daemonize]
|
55
|
+
pid = fork &start_server
|
56
|
+
Process.detach(pid)
|
57
|
+
else
|
58
|
+
start_server.call
|
59
|
+
end
|
60
|
+
sleep 0.1
|
61
|
+
if Oria::Server.running?
|
62
|
+
puts "Oria listening on #{@options[:host]}:#{@options[:port]}"
|
53
63
|
end
|
54
|
-
Process.detach(pid)
|
55
|
-
sleep 0.5
|
56
|
-
puts "Oria started successfull on proccess ##{pid}"
|
57
64
|
end
|
58
65
|
|
59
66
|
def self.stop
|
60
67
|
puts "Stopping Oria..."
|
61
|
-
|
62
|
-
|
63
|
-
|
68
|
+
if Oria::Server.stop
|
69
|
+
puts "Stopped!"
|
70
|
+
else
|
71
|
+
puts "Oria does not appear to be running."
|
72
|
+
end
|
64
73
|
end
|
65
74
|
end
|
66
75
|
|
data/lib/oria/client.rb
CHANGED
@@ -8,7 +8,10 @@ module Oria
|
|
8
8
|
|
9
9
|
def receive_data(data)
|
10
10
|
@response = JSON.parse(data)
|
11
|
-
close_connection
|
11
|
+
# close_connection
|
12
|
+
# Note: Benchmarks found that calling stop_event_loop is slightly quicker
|
13
|
+
# than close_connection, which navigates the connection closing.
|
14
|
+
EventMachine.stop_event_loop
|
12
15
|
end
|
13
16
|
|
14
17
|
def unbind
|
data/lib/oria/server.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'tmpdir'
|
3
|
+
|
3
4
|
module Oria
|
4
5
|
class Server < EventMachine::Connection
|
5
6
|
class << self
|
@@ -10,7 +11,11 @@ module Oria
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def log(value, app_key = nil)
|
13
|
-
|
14
|
+
if debug? || @@options[:puts]
|
15
|
+
value = "#{Time.now.strftime('%d %b %H:%M:%S')} - #{"#{app_key}: " if app_key}#{value}"
|
16
|
+
logger.debug(value) if debug?
|
17
|
+
puts value if @@options[:puts]
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
def logger
|
@@ -18,34 +23,49 @@ module Oria
|
|
18
23
|
@@logger ||= Logger.new(log_file, 0, 100 * 1024 * 1024)
|
19
24
|
end
|
20
25
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def running?
|
27
|
+
pid && !!Process.getpgid(pid)
|
28
|
+
rescue Errno::ESRCH
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def start(server, port, debug = false, options = {})
|
33
|
+
@@debug = !!debug
|
34
|
+
@@options = options
|
35
|
+
log "Server started"
|
30
36
|
@@servers ||= if File.exists?(yaml_store)
|
37
|
+
log "DB loaded from disk"
|
31
38
|
YAML.load_file(yaml_store)
|
32
39
|
else
|
33
40
|
{}
|
34
41
|
end
|
35
|
-
|
36
|
-
@@servers[app_key] ||= {}
|
42
|
+
pid = Process.pid
|
37
43
|
EventMachine.run do
|
38
44
|
EventMachine.start_server server, port, Oria::Server
|
45
|
+
File.open(pid_file, 'w') do |file|
|
46
|
+
file.puts pid
|
47
|
+
end
|
48
|
+
log "The server is now ready to accept connections on port #{port}"
|
39
49
|
end
|
40
50
|
end
|
41
51
|
|
42
52
|
def stop
|
53
|
+
response = false
|
43
54
|
if File.exists?(pid_file)
|
44
|
-
|
45
|
-
|
55
|
+
begin
|
56
|
+
if pid
|
57
|
+
Process.kill(9, pid)
|
58
|
+
response = true
|
59
|
+
end
|
60
|
+
rescue Errno::ESRCH
|
61
|
+
# TODO: We perform error reporting elsewhere. Still,
|
62
|
+
# an actionless rescue doesn't seem like a great idea.
|
63
|
+
ensure
|
64
|
+
File.unlink(pid_file)
|
65
|
+
@@pid = nil
|
46
66
|
end
|
47
|
-
File.unlink(pid_file)
|
48
67
|
end
|
68
|
+
response
|
49
69
|
end
|
50
70
|
|
51
71
|
def store_hash(app_key)
|
@@ -120,7 +140,7 @@ module Oria
|
|
120
140
|
|
121
141
|
private
|
122
142
|
def hash
|
123
|
-
@hash ||= @@servers[@app_key
|
143
|
+
@hash ||= @@servers[@app_key && !@app_key.empty? ? @app_key : 'default'] ||= {}
|
124
144
|
end
|
125
145
|
|
126
146
|
def random_key
|
data/lib/oria.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'eventmachine'
|
4
4
|
require 'json'
|
5
5
|
require 'oria/errors'
|
6
|
+
require 'tmpdir'
|
6
7
|
|
7
8
|
module Oria
|
8
9
|
autoload(:Client, 'oria/client')
|
@@ -25,34 +26,25 @@ module Oria
|
|
25
26
|
@@app_key = key.to_s
|
26
27
|
end
|
27
28
|
|
28
|
-
def self.auto_start
|
29
|
-
@@pid = fork do
|
30
|
-
Oria::Server.start(Oria.server, Oria.port, Oria.app_key)
|
31
|
-
end
|
32
|
-
Process.detach(@@pid)
|
33
|
-
at_exit {
|
34
|
-
Process.kill("HUP", @@pid)
|
35
|
-
}
|
36
|
-
sleep 1
|
37
|
-
end
|
38
|
-
|
39
29
|
def self.clear
|
40
30
|
store(:delete)
|
41
31
|
end
|
42
32
|
|
43
|
-
def self.connect(server, port =
|
44
|
-
@@server = server
|
33
|
+
def self.connect(server = Oria.server, port = Oria.port, debug = false)
|
34
|
+
@@server = server.to_s
|
45
35
|
@@port = port.to_i unless port.to_i == 0
|
36
|
+
unless Oria::Server.running?
|
37
|
+
# That's right. Boot Oria on the command line so we don't bother forking or any
|
38
|
+
# of that other troublesome nonsense. It's smart enough to maintain its own
|
39
|
+
# status and start/stop/restart itself.
|
40
|
+
system("./bin/oria start -d -h #{@@server} -p #{@@port}")
|
41
|
+
end
|
46
42
|
end
|
47
43
|
|
48
44
|
def self.delete(key)
|
49
45
|
store(:delete, :key => key)
|
50
46
|
end
|
51
47
|
|
52
|
-
def self.disconnect
|
53
|
-
Oria::Server.stop
|
54
|
-
end
|
55
|
-
|
56
48
|
def self.has_key?(key)
|
57
49
|
key?(key)
|
58
50
|
end
|
@@ -90,7 +82,13 @@ module Oria
|
|
90
82
|
args = JSON.generate(args)
|
91
83
|
do_store(method, args)
|
92
84
|
rescue Oria::ConnectionError
|
93
|
-
|
85
|
+
# Thanks to ActiveSupport for the "silence_stream" functionality - we're quieting STDOUT
|
86
|
+
# at autoconnect time.
|
87
|
+
old_stream = STDOUT.dup
|
88
|
+
STDOUT.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
|
89
|
+
STDOUT.sync = true
|
90
|
+
connect
|
91
|
+
STDOUT.reopen(old_stream)
|
94
92
|
do_store(method, args)
|
95
93
|
end
|
96
94
|
end
|
data/oria.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{oria}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Flip Sasser"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-27}
|
13
13
|
s.default_executable = %q{oria}
|
14
14
|
s.description = %q{
|
15
15
|
Oria (oh-rye-uh) is an in-memory, Ruby-based Key-Value store. It's designed to handle moderate amounts of data quickly
|
@@ -28,10 +28,17 @@ Gem::Specification.new do |s|
|
|
28
28
|
"README.markdown",
|
29
29
|
"Rakefile",
|
30
30
|
"VERSION",
|
31
|
-
"benchmarks/
|
31
|
+
"benchmarks/em_stop_v_disconnect.rb",
|
32
|
+
"benchmarks/eventmachine/client.rb",
|
33
|
+
"benchmarks/eventmachine/tcp_server.rb",
|
34
|
+
"benchmarks/eventmachine/udp_server.rb",
|
35
|
+
"benchmarks/hash_v_redis.rb",
|
36
|
+
"benchmarks/mysql_v_oria.rb",
|
32
37
|
"benchmarks/redis_v_oria.rb",
|
33
|
-
"benchmarks/sequel_v_oria.rb",
|
34
38
|
"benchmarks/sqlite_v_oria.rb",
|
39
|
+
"benchmarks/support/mysql_table.sql",
|
40
|
+
"benchmarks/tcp_v_redis.rb",
|
41
|
+
"benchmarks/udp_v_redis.rb",
|
35
42
|
"bin/oria",
|
36
43
|
"lib/oria.rb",
|
37
44
|
"lib/oria/client.rb",
|
data/spec/oria_spec.rb
CHANGED
@@ -28,128 +28,125 @@ describe Oria do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
it "should support per-app keys" do
|
36
|
-
Oria.should respond_to(:app_key)
|
37
|
-
Oria.should respond_to(:app_key=)
|
38
|
-
end
|
31
|
+
describe "class methods" do
|
32
|
+
it "should provide a connect method" do
|
33
|
+
Oria.should respond_to(:connect)
|
34
|
+
end
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
36
|
+
it "should support per-app keys" do
|
37
|
+
Oria.should respond_to(:app_key)
|
38
|
+
Oria.should respond_to(:app_key=)
|
39
|
+
end
|
45
40
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
41
|
+
it "should support custom connections" do
|
42
|
+
Oria.connect("127.0.0.1", 4567)
|
43
|
+
Oria.server.should == "127.0.0.1"
|
44
|
+
Oria.port.should == 4567
|
45
|
+
Oria::Server.stop
|
46
|
+
sleep 1
|
47
|
+
end
|
50
48
|
end
|
51
49
|
|
52
50
|
describe "app_key" do
|
53
51
|
# it "should default to nil" do
|
54
52
|
# # This is bleeding over from the last example below. Frankly,
|
55
|
-
# # I don't know how to fix it.
|
53
|
+
# # I don't know how to fix it. I'm unclear on separating
|
54
|
+
# # Rspec examples from each other at the class level like
|
55
|
+
# # this.
|
56
56
|
# Oria.app_key.should be_nil
|
57
57
|
# end
|
58
|
-
|
58
|
+
|
59
59
|
it "should be configurable" do
|
60
60
|
Oria.app_key = "test_app"
|
61
61
|
Oria.app_key.should == "test_app"
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe "setting values" do
|
66
|
+
before :all do
|
67
|
+
Oria.connect
|
68
|
+
sleep 1
|
69
|
+
end
|
64
70
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
after :all do
|
72
|
+
# TODO: In general, I find "sleep" to be a terrible method of doing anything.
|
73
|
+
# Still, it gets the job done, albeit by delaying our specs.
|
74
|
+
Oria::Server.stop
|
75
|
+
sleep 0.5
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should set string values" do
|
79
|
+
Oria["foo"] = "bar"
|
80
|
+
Oria["foo"].should == "bar"
|
81
|
+
end
|
70
82
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
Oria["key_check"] = "check-a-key"
|
132
|
-
Oria.key?("key_check").should be_true
|
133
|
-
Oria.key?("key_check_broken").should be_false
|
134
|
-
Oria.has_key?("key_check").should be_true
|
135
|
-
Oria.has_key?("key_check_broken").should be_false
|
136
|
-
end
|
137
|
-
|
138
|
-
it "should support stashing" do
|
139
|
-
key = Oria.stash("foobar")
|
140
|
-
key.should_not be_nil
|
141
|
-
Oria[key].should == "foobar"
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should support different app_keys" do
|
145
|
-
Oria.app_key = "test_app_1"
|
146
|
-
Oria["test_app_1"] = "bar"
|
147
|
-
Oria["test_app_1"].should == "bar"
|
148
|
-
Oria.app_key = "test_app_2"
|
149
|
-
Oria["test_app_2"] = "baz"
|
150
|
-
Oria["test_app_1"].should be_nil
|
151
|
-
Oria["test_app_2"].should == "baz"
|
152
|
-
end
|
83
|
+
it "should set integer values" do
|
84
|
+
Oria["foo"] = 12
|
85
|
+
Oria["foo"].should == 12
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should support Hashes" do
|
89
|
+
Oria["foo"] = {"Flip" => "Sasser"}
|
90
|
+
Oria["foo"].should == {"Flip" => "Sasser"}
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should support Arrays" do
|
94
|
+
Oria["foo"] = ["Foo", "Bar", "Baz"]
|
95
|
+
Oria["foo"].should == ["Foo", "Bar", "Baz"]
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should support Booleans" do
|
99
|
+
Oria["true"] = false
|
100
|
+
Oria["true"].should == false
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should support deleting values" do
|
104
|
+
Oria["memoria"] = "foobar"
|
105
|
+
Oria["dont_delete"] = "please"
|
106
|
+
Oria.delete("memoria").should == "foobar"
|
107
|
+
Oria["memora"].should be_nil
|
108
|
+
Oria["dont_delete"].should == "please"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should support complete clearing" do
|
112
|
+
Oria["a"] = "c"
|
113
|
+
Oria["b"] = "d"
|
114
|
+
Oria["a"].should == "c"
|
115
|
+
Oria["b"].should == "d"
|
116
|
+
Oria.clear
|
117
|
+
Oria["a"].should be_nil
|
118
|
+
Oria["b"].should be_nil
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should support key-checking" do
|
122
|
+
Oria["key_check"] = "check-a-key"
|
123
|
+
Oria.key?("key_check").should be_true
|
124
|
+
Oria.key?("key_check_broken").should be_false
|
125
|
+
Oria.has_key?("key_check").should be_true
|
126
|
+
Oria.has_key?("key_check_broken").should be_false
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should support stashing" do
|
130
|
+
key = Oria.stash("foobar")
|
131
|
+
key.should_not be_nil
|
132
|
+
Oria[key].should == "foobar"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should support different app_keys" do
|
136
|
+
Oria.app_key = "test_app_1"
|
137
|
+
Oria["test_app_1"] = "bar"
|
138
|
+
Oria["test_app_1"].should == "bar"
|
139
|
+
Oria.app_key = "test_app_2"
|
140
|
+
Oria["test_app_2"] = "baz"
|
141
|
+
Oria["test_app_1"].should be_nil
|
142
|
+
Oria["test_app_2"].should == "baz"
|
153
143
|
end
|
154
144
|
end
|
145
|
+
|
146
|
+
# it "should automatically boot a server" do
|
147
|
+
# Oria.should_receive(:connect)
|
148
|
+
# Oria["foo"] = "bar"
|
149
|
+
# Oria["foo"].should == "bar"
|
150
|
+
# Oria::Server.stop
|
151
|
+
# end
|
155
152
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oria
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flip Sasser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-27 00:00:00 -05:00
|
13
13
|
default_executable: oria
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -47,10 +47,17 @@ files:
|
|
47
47
|
- README.markdown
|
48
48
|
- Rakefile
|
49
49
|
- VERSION
|
50
|
-
- benchmarks/
|
50
|
+
- benchmarks/em_stop_v_disconnect.rb
|
51
|
+
- benchmarks/eventmachine/client.rb
|
52
|
+
- benchmarks/eventmachine/tcp_server.rb
|
53
|
+
- benchmarks/eventmachine/udp_server.rb
|
54
|
+
- benchmarks/hash_v_redis.rb
|
55
|
+
- benchmarks/mysql_v_oria.rb
|
51
56
|
- benchmarks/redis_v_oria.rb
|
52
|
-
- benchmarks/sequel_v_oria.rb
|
53
57
|
- benchmarks/sqlite_v_oria.rb
|
58
|
+
- benchmarks/support/mysql_table.sql
|
59
|
+
- benchmarks/tcp_v_redis.rb
|
60
|
+
- benchmarks/udp_v_redis.rb
|
54
61
|
- bin/oria
|
55
62
|
- lib/oria.rb
|
56
63
|
- lib/oria/client.rb
|