redis-objects 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/Rakefile +1 -0
- data/lib/redis/base_object.rb +3 -1
- data/lib/redis/hash_key.rb +1 -1
- data/lib/redis/objects.rb +1 -1
- data/lib/redis/objects/version.rb +1 -1
- data/lib/redis/set.rb +3 -1
- data/spec/redis_objects_conn_spec.rb +11 -0
- data/spec/redis_objects_instance_spec.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db06e487bea5d7ea6fe9524c0309fe4bac4c959a
|
4
|
+
data.tar.gz: 332266c573fa0b396ecd35b1f95c0923e9e2a8a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9440f03a1c478a8f0fd4fdb15a22ddab2656ae315210b235cc31d0bed929aff90ec06afb8b93f9bd68253bdabbf115dd14bee8e14504e648682d7e870940d68
|
7
|
+
data.tar.gz: 0fa8ff012020af2740020fcc58d86473ffe8deed5fe487cd546d4007c86666b0642720fe0d703fc343905a3853fc5a9256ecaca29ba0302de5dfd105b377df6b
|
data/README.md
CHANGED
@@ -289,7 +289,7 @@ You can bound the size of the list to only hold N elements like so:
|
|
289
289
|
@list = Redis::List.new('list_name', :maxlength => 10)
|
290
290
|
~~~
|
291
291
|
|
292
|
-
Complex data types are
|
292
|
+
Complex data types are serialized with :marshal => true:
|
293
293
|
|
294
294
|
~~~ruby
|
295
295
|
@list = Redis::List.new('list_name', :marshal => true)
|
@@ -300,6 +300,8 @@ Complex data types are now handled with :marshal => true:
|
|
300
300
|
end
|
301
301
|
~~~
|
302
302
|
|
303
|
+
Note: If you run into issues, with Marshal errors, refer to the fix in [Issue #176](https://github.com/nateware/redis-objects/issues/176).
|
304
|
+
|
303
305
|
Hashes
|
304
306
|
------
|
305
307
|
Hashes work like a Ruby [Hash](http://ruby-doc.org/core/classes/Hash.html), with
|
data/Rakefile
CHANGED
data/lib/redis/base_object.rb
CHANGED
data/lib/redis/hash_key.rb
CHANGED
@@ -118,7 +118,7 @@ class Redis
|
|
118
118
|
|
119
119
|
# Set keys in bulk if they do not exist. Takes a hash of field/values {'field1' => 'val1'}. Redis: HSETNX
|
120
120
|
def fill(pairs={})
|
121
|
-
raise ArgumentError, "
|
121
|
+
raise ArgumentError, "Argument to fill must be a hash of key/value pairs" unless pairs.is_a?(::Hash)
|
122
122
|
allow_expiration do
|
123
123
|
pairs.each do |field, value|
|
124
124
|
redis.hsetnx(key, field, marshal(value, options[:marshal_keys][field]))
|
data/lib/redis/objects.rb
CHANGED
@@ -28,7 +28,7 @@ class Redis
|
|
28
28
|
# set :player_ids
|
29
29
|
# end
|
30
30
|
#
|
31
|
-
# The, you can use these counters both for
|
31
|
+
# The, you can use these counters both for bookkeeping and as atomic actions:
|
32
32
|
#
|
33
33
|
# @game = Game.find(id)
|
34
34
|
# @game_user = @game.joined_players.increment do |val|
|
data/lib/redis/set.rb
CHANGED
@@ -39,7 +39,9 @@ class Redis
|
|
39
39
|
# Adds the specified values to the set. Only works on redis > 2.4
|
40
40
|
# Redis: SADD
|
41
41
|
def merge(*values)
|
42
|
-
|
42
|
+
allow_expiration do
|
43
|
+
redis.sadd(key, values.flatten.map{|v| marshal(v)})
|
44
|
+
end
|
43
45
|
end
|
44
46
|
|
45
47
|
# Return all members in the set. Redis: SMEMBERS
|
@@ -240,4 +240,15 @@ describe 'Connection tests' do
|
|
240
240
|
# Fix for future tests
|
241
241
|
Redis.current = @redis_handle
|
242
242
|
end
|
243
|
+
|
244
|
+
it "should support pipelined changes" do
|
245
|
+
list = Redis::List.new('pipelined/list')
|
246
|
+
key = Redis::HashKey.new('pipelined/hash')
|
247
|
+
Redis::Objects.redis.pipelined do
|
248
|
+
key['foo'] = 'bar'
|
249
|
+
list.push 1, 2
|
250
|
+
end
|
251
|
+
key.all.should == { 'foo' => 'bar' }
|
252
|
+
list.values.should == %w[1 2]
|
253
|
+
end
|
243
254
|
end
|
@@ -1035,7 +1035,7 @@ describe Redis::Set do
|
|
1035
1035
|
end
|
1036
1036
|
|
1037
1037
|
describe "with expiration" do
|
1038
|
-
[:<<, :add].each do |meth|
|
1038
|
+
[:<<, :add, :merge].each do |meth|
|
1039
1039
|
it "should set time to live in seconds when expiration option assigned" do
|
1040
1040
|
@set = Redis::Set.new('spec/set', :expiration => 10)
|
1041
1041
|
@set.send(meth, 'val')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Wiger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '4.2'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '4.2'
|
111
111
|
description: Map Redis types directly to Ruby objects. Works with any class or ORM.
|
112
112
|
email:
|
113
113
|
- nwiger@gmail.com
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.4.5
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Map Redis types directly to Ruby objects
|