ohm 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDVlZWJhMjlkNWUzM2Y2NzY3ODVmN2E3YmIxYjQ3ZmU3OGQ3N2JiOA==
5
- data.tar.gz: !binary |-
6
- ZGMyODFlYTAwYzU0MzE4MTQ0Y2FhZTNlZTdhODU0YzgwYTgyZjA4Mw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NGY2YmU4YTE0NWQ3N2E4Y2QyYWViZDBiOWUwM2NmMTFhNjY5YjNmMTIxNmE3
10
- OTRhNmJiMjQ2ZjcwNDQwMjU4YTQ3ZWRjZmJjMmZlOTIxMTY3OTA5ZGJkNDYy
11
- Yjg0ZDllODdkNjM4NGFmNWM4YzY5MTQ0ODBlYTNkYjhkODhmOGE=
12
- data.tar.gz: !binary |-
13
- ZTJiYWNjNGUxZTk1ZTUxNTQ5Nzk2NTZmOGQ1YTAzY2QzY2Y2NDk4MGE5MDU3
14
- Zjk1ODY3MThlYTdmOGZhZWFiY2QyNzg1MTg2YjA5NjFlODE4NDNjNmE4N2Mx
15
- MmJlNjg3ZjViYzc4NmU5ZGNlNmU1MmEwMmNkMDBhOTg1ZDUyZjk=
2
+ SHA1:
3
+ metadata.gz: a0015a7962f27903ee712ca027655b3f01722f64
4
+ data.tar.gz: 06c1b5a4101dae29fbabd19d6804a0eafbb3ccd3
5
+ SHA512:
6
+ metadata.gz: 6ea9f1a1f47e0863607e97f6c6d3e5c2673a355fadca8baa88f30636028b404a08dce69a26d9489272896abd734ccdcd3535eebe4807ae740a8a4b37a6b8a8b0
7
+ data.tar.gz: 88ee32f78b6ce100d028ecfc1dfe5d61e4e9ec6933c0261df4828d4c63835108aba23b30ea69259717e0cae5f06df8aa31ac1aadc0f1200d8d2bac255a9c249e
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ (unreleased)
2
+
3
+ - Fetching a batch of objects is now done in batches of 1000 objects at
4
+ a time. If you are iterating over large collections, this change should
5
+ provide a significant performance boost both in used memory and total
6
+ execution time.
7
+ - MutableSet#<< is now an alias for #add.
8
+
1
9
  1.3.1
2
10
 
3
11
  - Improve memory consumption when indexing persisted attributes.
data/README.md CHANGED
@@ -31,7 +31,7 @@ These are libraries in other languages that were inspired by Ohm.
31
31
  Articles and Presentations
32
32
  --------------------------
33
33
 
34
- * [Simplicty](http://files.soveran.com/simplicity)
34
+ * [Simplicity](http://files.soveran.com/simplicity)
35
35
  * [How to Redis](http://www.paperplanes.de/2009/10/30/how_to_redis.html)
36
36
  * [Redis and Ohm](http://carlopecchia.eu/blog/2010/04/30/redis-and-ohm-part1/)
37
37
  * [Ohm (Redis ORM)](http://blog.s21g.com/articles/1717) (Japanese)
data/lib/ohm.rb CHANGED
@@ -145,7 +145,9 @@ module Ohm
145
145
 
146
146
  def each
147
147
  if block_given?
148
- to_a.each { |element| yield element }
148
+ ids.each_slice(1000) do |slice|
149
+ fetch(slice).each { |e| yield(e) }
150
+ end
149
151
  else
150
152
  Enumerator.new(self, :each)
151
153
  end
@@ -503,6 +505,8 @@ module Ohm
503
505
  db.sadd(key, model.id)
504
506
  end
505
507
 
508
+ alias_method :<<, :add
509
+
506
510
  # Remove a model directly from the set.
507
511
  #
508
512
  # Example:
@@ -783,7 +787,7 @@ module Ohm
783
787
  raise IndexNotFound unless uniques.include?(att)
784
788
 
785
789
  id = db.hget(key[:uniques][att], val)
786
- id && self[id]
790
+ new(:id => id).load! if id
787
791
  end
788
792
 
789
793
  # Find values in indexed fields.
@@ -1343,7 +1347,8 @@ module Ohm
1343
1347
  transaction do |t|
1344
1348
  _uniques = nil
1345
1349
  _indices = nil
1346
- existing = nil
1350
+ existing_indices = nil
1351
+ existing_uniques = nil
1347
1352
 
1348
1353
  t.watch(*_unique_keys)
1349
1354
 
@@ -1352,7 +1357,8 @@ module Ohm
1352
1357
  t.watch(key[:_uniques]) if model.uniques.any?
1353
1358
 
1354
1359
  t.read do
1355
- existing = _read_attributes(model.indices) if model.indices.any?
1360
+ existing_indices = _read_attributes(model.indices) if model.indices.any?
1361
+ existing_uniques = _read_attributes(model.uniques) if model.uniques.any?
1356
1362
  _uniques = db.hgetall(key[:_uniques])
1357
1363
  _indices = db.smembers(key[:_indices])
1358
1364
  end
@@ -1360,7 +1366,8 @@ module Ohm
1360
1366
  t.write do
1361
1367
  _delete_uniques(_uniques)
1362
1368
  _delete_indices(_indices)
1363
- _delete_existing_indices(existing)
1369
+ _delete_existing_uniques(existing_uniques)
1370
+ _delete_existing_indices(existing_indices)
1364
1371
  model.collections.each { |e| db.del(key[e]) }
1365
1372
  db.srem(model.key[:all], id)
1366
1373
  db.del(key[:counters])
data/ohm.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "ohm"
3
- s.version = "1.3.1"
3
+ s.version = "1.3.2"
4
4
  s.summary = %{Object-hash mapping library for Redis.}
5
5
  s.description = %Q{Ohm is a library that allows to store an object in Redis, a persistent key-value database. It includes an extensible list of validations and has very good performance.}
6
6
  s.authors = ["Michel Martens", "Damian Janowski", "Cyril David"]
data/test/uniques.rb CHANGED
@@ -64,7 +64,7 @@ test "removes the previous index when changing" do
64
64
  u.update(:email => "d@d.com")
65
65
 
66
66
  assert_equal nil, User.with(:email, "c@c.com")
67
- assert_equal nil, User.key[:unique][:email].hget("c@c.com")
67
+ assert_equal nil, User.key[:uniques][:email].hget("c@c.com")
68
68
  assert_equal u, User.with(:email, "d@d.com")
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ test "removes the previous index when deleting" do |u|
72
72
  u.delete
73
73
 
74
74
  assert_equal nil, User.with(:email, "a@a.com")
75
- assert_equal nil, User.key[:unique][:email].hget("a@a.com")
75
+ assert_equal nil, User.key[:uniques][:email].hget("a@a.com")
76
76
  end
77
77
 
78
78
  test "unique virtual attribute" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
@@ -10,20 +10,20 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-02 00:00:00.000000000 Z
13
+ date: 2013-04-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: redis
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ! '>='
19
+ - - '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ! '>='
26
+ - - '>='
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
29
  - !ruby/object:Gem::Dependency
@@ -133,17 +133,17 @@ require_paths:
133
133
  - lib
134
134
  required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - '>='
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - ! '>='
141
+ - - '>='
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project: ohm
146
- rubygems_version: 2.0.0
146
+ rubygems_version: 2.0.3
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: Object-hash mapping library for Redis.