redpear 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/redpear/connection.rb +10 -7
- data/lib/redpear/model.rb +3 -5
- data/lib/redpear/store/base.rb +11 -7
- data/lib/redpear/store/list.rb +2 -2
- data/lib/redpear/store/sorted_set.rb +12 -10
- data/lib/redpear/version.rb +2 -2
- metadata +60 -20
data/lib/redpear/connection.rb
CHANGED
@@ -7,11 +7,14 @@ class Redpear::Connection
|
|
7
7
|
|
8
8
|
MASTER_METHODS = [
|
9
9
|
:append, :blpop, :brpop, :brpoplpush, :decr, :decrby, :del, :discard,
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
10
|
+
:eval, :evalsha, :exec, :expire, :expireat, :getset,
|
11
|
+
:hset, :hsetnx, :hincrby, :hmset, :hdel, :hincrbyfloat,
|
12
|
+
:incr, :incrby, :incrbyfloat,
|
13
|
+
:linsert, :lpop, :lpush, :lpushx, :lrem, :lset, :ltrim,
|
14
|
+
:mapped_hmset, :mapped_mset, :mapped_msetnx, :move, :mset, :msetnx,
|
13
15
|
:multi, :persist, :pipelined, :rename, :renamenx, :rpop, :rpoplpush,
|
14
|
-
:
|
16
|
+
:pexpire, :pexpireat, :psetex, :pttl, :rpush, :rpushx,
|
17
|
+
:sadd, :script, :sdiffstore, :set, :setbit, :setex, :setnx,
|
15
18
|
:setrange, :sinterstore, :smove, :spop, :srem, :sunionstore, :unwatch,
|
16
19
|
:watch, :zadd, :zincrby, :zinterstore, :zrem, :zremrangebyrank,
|
17
20
|
:zremrangebyscore, :zunionstore, :[]=
|
@@ -23,9 +26,9 @@ class Redpear::Connection
|
|
23
26
|
:hlen, :hkeys, :hvals, :hgetall, :info, :keys, :lastsave, :lindex, :llen,
|
24
27
|
:lrange, :mapped_hmget, :mapped_mget, :mget, :monitor, :object, :ping,
|
25
28
|
:publish, :psubscribe, :punsubscribe, :quit, :randomkey, :save, :scard,
|
26
|
-
:sdiff, :select, :shutdown, :sinter, :sismember, :slaveof, :smembers,
|
27
|
-
:sort, :srandmember, :strlen, :subscribe, :subscribed?, :
|
28
|
-
:
|
29
|
+
:sdiff, :select, :shutdown, :sinter, :sismember, :slaveof, :slowlog, :smembers,
|
30
|
+
:sort, :srandmember, :strlen, :subscribe, :subscribed?, :sunion, :sync, :synchronize,
|
31
|
+
:time, :ttl, :type, :unsubscribe, :zcard, :zcount, :zrange,
|
29
32
|
:zrangebyscore, :zrank, :zrevrange, :zrevrangebyscore, :zrevrank, :zscore,
|
30
33
|
:[]
|
31
34
|
].freeze
|
data/lib/redpear/model.rb
CHANGED
@@ -214,11 +214,9 @@ class Redpear::Model < Hash
|
|
214
214
|
# @return [Boolean] true if successful
|
215
215
|
def destroy
|
216
216
|
before_destroy
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
after_destroy
|
221
|
-
end
|
217
|
+
lookups.each {|l| l.delete(id) }
|
218
|
+
attributes.purge!
|
219
|
+
after_destroy
|
222
220
|
freeze
|
223
221
|
end
|
224
222
|
|
data/lib/redpear/store/base.rb
CHANGED
@@ -51,8 +51,8 @@ class Redpear::Store::Base
|
|
51
51
|
|
52
52
|
# Watch this key
|
53
53
|
# @return [Boolean] true if successful
|
54
|
-
def watch
|
55
|
-
conn.watch(key)
|
54
|
+
def watch(&block)
|
55
|
+
conn.watch(key, &block).nil?
|
56
56
|
end
|
57
57
|
|
58
58
|
# @return [Integer] remaining time-to-live in seconds (if set)
|
@@ -115,11 +115,15 @@ class Redpear::Store::Base
|
|
115
115
|
|
116
116
|
private
|
117
117
|
|
118
|
-
def range_pair(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
118
|
+
def range_pair(value, reversed = false)
|
119
|
+
case value
|
120
|
+
when Range
|
121
|
+
first, last = value.first.to_i, value.last.to_i
|
122
|
+
last -= 1 if value.exclude_end?
|
123
|
+
reversed ? [last, first] : [first, last]
|
124
|
+
when Array
|
125
|
+
[value.first, value.last]
|
126
|
+
end
|
123
127
|
end
|
124
128
|
|
125
129
|
end
|
data/lib/redpear/store/list.rb
CHANGED
@@ -34,7 +34,7 @@ class Redpear::Store::List < Redpear::Store::Enumerable
|
|
34
34
|
else
|
35
35
|
conn.lindex(key, start) rescue nil
|
36
36
|
end
|
37
|
-
when Range
|
37
|
+
when Range, Array
|
38
38
|
range *range_pair(start)
|
39
39
|
else
|
40
40
|
[]
|
@@ -46,7 +46,7 @@ class Redpear::Store::List < Redpear::Store::Enumerable
|
|
46
46
|
# @overload slice(start, length)
|
47
47
|
def slice!(start, length = nil)
|
48
48
|
case start
|
49
|
-
when Range
|
49
|
+
when Range, Array
|
50
50
|
trim *range_pair(start)
|
51
51
|
else
|
52
52
|
trim(start, start + length - 1)
|
@@ -23,6 +23,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
23
23
|
end
|
24
24
|
alias_method :size, :length
|
25
25
|
|
26
|
+
# Returns items from range
|
26
27
|
# @param [Range] range
|
27
28
|
# @return [Integer] the number of items within given score `range`
|
28
29
|
def count(range)
|
@@ -86,7 +87,6 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
86
87
|
|
87
88
|
# Returns a slice of members between index +range+, with the lower index returned first
|
88
89
|
# @param [Range] range
|
89
|
-
# The index range of the elements
|
90
90
|
# @param [Hash] options
|
91
91
|
# @option [Boolean] with_scores
|
92
92
|
# Return with scores, defaults to true
|
@@ -98,8 +98,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
98
98
|
alias_method :top, :slice
|
99
99
|
|
100
100
|
# Returns a slice of members between rindex +range+, with the higher index returned first
|
101
|
-
# @param [Range] range
|
102
|
-
# The rindex range of the elements
|
101
|
+
# @param [Range] range The rindex range of the elements
|
103
102
|
# @param [Hash] options
|
104
103
|
# @option [Boolean] with_scores
|
105
104
|
# Return with scores, defaults to true
|
@@ -111,8 +110,10 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
111
110
|
alias_method :bottom, :rslice
|
112
111
|
|
113
112
|
# Selects members between a score +range+. Lower scores returned first
|
114
|
-
# @
|
115
|
-
# The score range of the elements
|
113
|
+
# @overload select(range)
|
114
|
+
# @param [Range] range The score range of the elements
|
115
|
+
# @overload select(range)
|
116
|
+
# @param [Array] range as Array, e.g. ["-inf", "+inf"]
|
116
117
|
# @param [Hash] options
|
117
118
|
# @option [Boolean] with_scores
|
118
119
|
# Return with scores, defaults to true
|
@@ -125,8 +126,10 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
125
126
|
end
|
126
127
|
|
127
128
|
# Selects members between a score +range+. Higher scores returned first
|
128
|
-
# @
|
129
|
-
# The score range of the elements
|
129
|
+
# @overload rselect(range)
|
130
|
+
# @param [Range] range The score range of the elements
|
131
|
+
# @overload rselect(range)
|
132
|
+
# @param [Array] range as Array, e.g. ["-inf", "+inf"]
|
130
133
|
# @param [Hash] options
|
131
134
|
# @option [Boolean] with_scores
|
132
135
|
# Return with scores, defaults to true
|
@@ -134,7 +137,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
134
137
|
# Limit the results
|
135
138
|
# @return [Array] the members
|
136
139
|
def rselect(range, options = {})
|
137
|
-
|
140
|
+
finish, start = range_pair(range, true)
|
138
141
|
fetch_range :zrevrangebyscore, finish, start, options
|
139
142
|
end
|
140
143
|
|
@@ -232,8 +235,7 @@ class Redpear::Store::SortedSet < Redpear::Store::Enumerable
|
|
232
235
|
def fetch_range(method, start, finish, options = {})
|
233
236
|
options[:limit] = [options[:offset] || 0, options[:limit]] if options[:offset] || options[:limit]
|
234
237
|
options[:with_scores] = true unless options.key?(:with_scores)
|
235
|
-
|
236
|
-
options[:with_scores] ? result.each_slice(2).map {|m,s| [m, s.to_f] } : result
|
238
|
+
conn.send method, key, start, finish, options
|
237
239
|
end
|
238
240
|
|
239
241
|
end
|
data/lib/redpear/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redpear
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 3.0.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.0.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: bundler
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: rspec
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: shoulda-matchers
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: machinist
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: factory_girl
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,10 +117,15 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: hiredis
|
93
|
-
requirement:
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
94
129
|
none: false
|
95
130
|
requirements:
|
96
131
|
- - ! '>='
|
@@ -98,7 +133,12 @@ dependencies:
|
|
98
133
|
version: '0'
|
99
134
|
type: :development
|
100
135
|
prerelease: false
|
101
|
-
version_requirements:
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
102
142
|
description: Simple, elegant & efficient ORM for Redis
|
103
143
|
email: dimitrij@blacksquaremedia.com
|
104
144
|
executables: []
|
@@ -149,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
189
|
version: 1.3.6
|
150
190
|
requirements: []
|
151
191
|
rubyforge_project:
|
152
|
-
rubygems_version: 1.8.
|
192
|
+
rubygems_version: 1.8.24
|
153
193
|
signing_key:
|
154
194
|
specification_version: 3
|
155
195
|
summary: Redpear, a Redis ORM
|