uorm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/uorm.rb +0 -1
- data/lib/uorm/dsl.rb +2 -2
- data/lib/uorm/em-mongo/db.rb +9 -3
- data/lib/uorm/redis.rb +1 -1
- data/lib/uorm/redis/db.rb +8 -2
- data/lib/uorm/redis/persistance.rb +4 -1
- data/lib/uorm/version.rb +1 -1
- data/spec/redis_synchrony_spec.rb +4 -1
- metadata +2 -2
data/lib/uorm.rb
CHANGED
data/lib/uorm/dsl.rb
CHANGED
data/lib/uorm/em-mongo/db.rb
CHANGED
@@ -2,18 +2,24 @@ module Uorm
|
|
2
2
|
module EM::Mongo
|
3
3
|
class DB
|
4
4
|
class << self
|
5
|
-
attr_accessor :name
|
5
|
+
attr_accessor :name, :pool_size
|
6
6
|
|
7
7
|
def collection coll
|
8
8
|
db.collection coll
|
9
9
|
end
|
10
10
|
|
11
11
|
def db
|
12
|
-
|
12
|
+
connection.db name
|
13
|
+
end
|
14
|
+
|
15
|
+
def pool_size
|
16
|
+
@pool_size ||= 2
|
13
17
|
end
|
14
18
|
|
15
19
|
def connection
|
16
|
-
@connection ||= ::EM::
|
20
|
+
@connection ||= ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
|
21
|
+
::EM::Mongo::Connection.new
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
data/lib/uorm/redis.rb
CHANGED
data/lib/uorm/redis/db.rb
CHANGED
@@ -2,10 +2,16 @@ module Uorm
|
|
2
2
|
module Redis
|
3
3
|
class DB
|
4
4
|
class << self
|
5
|
-
attr_accessor :nr
|
5
|
+
attr_accessor :nr, :pool_size
|
6
|
+
|
7
|
+
def pool_size
|
8
|
+
@pool_size ||= 2
|
9
|
+
end
|
6
10
|
|
7
11
|
def client
|
8
|
-
@client ||= ::
|
12
|
+
@client ||= ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
|
13
|
+
::Redis.new driver: :synchrony, db: nr
|
14
|
+
end
|
9
15
|
end
|
10
16
|
end
|
11
17
|
end
|
@@ -14,13 +14,16 @@ module Uorm
|
|
14
14
|
|
15
15
|
def all options = {}
|
16
16
|
keys = collection.keys
|
17
|
+
return [] if keys.empty?
|
18
|
+
|
17
19
|
collection.mget(keys).map do |val|
|
18
20
|
MultiJson.load val if val
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
def find id
|
23
|
-
|
25
|
+
data = collection.get id
|
26
|
+
MultiJson.load data if data
|
24
27
|
end
|
25
28
|
|
26
29
|
def create object
|
data/lib/uorm/version.rb
CHANGED
@@ -55,12 +55,15 @@ describe ARedisModel do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
|
59
58
|
describe '.all' do
|
60
59
|
it 'returns a collection of all objects' do
|
61
60
|
ARedisModel.create attributes
|
62
61
|
ARedisModel.all.should be_collection_of ARedisModel
|
63
62
|
end
|
63
|
+
|
64
|
+
it 'returns an empty array if the collection is empty' do
|
65
|
+
ARedisModel.all.should =~ []
|
66
|
+
end
|
64
67
|
end
|
65
68
|
|
66
69
|
describe '.find' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|