nomo 0.0.37 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nomo/conditional_get.rb +1 -1
- data/lib/nomo/model.rb +8 -8
- data/lib/nomo/page.rb +2 -7
- data/lib/nomo/version.rb +1 -1
- data/lib/nomo.rb +17 -20
- metadata +6 -6
data/lib/nomo/conditional_get.rb
CHANGED
@@ -6,7 +6,7 @@ module Nomo
|
|
6
6
|
if record_or_options.is_a? Nomo::Page
|
7
7
|
nomo_page = record_or_options
|
8
8
|
|
9
|
-
record_or_options = { etag: nomo_page.
|
9
|
+
record_or_options = { etag: [nomo_page.cache_key, *(layout_factors rescue nil)],
|
10
10
|
last_modified: nomo_page.last_modified }
|
11
11
|
|
12
12
|
response.headers['Nomo-Key'] = nomo_page.key if nomo_page.realtime?
|
data/lib/nomo/model.rb
CHANGED
@@ -2,20 +2,20 @@ module Nomo
|
|
2
2
|
module Model
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
+
included do
|
6
|
+
after_commit do
|
7
|
+
Nomo.exec
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def save(*)
|
6
12
|
Nomo.multi
|
7
|
-
|
8
|
-
Nomo.exec
|
9
|
-
|
10
|
-
return_value
|
13
|
+
super
|
11
14
|
end
|
12
15
|
|
13
16
|
def destroy
|
14
17
|
Nomo.multi
|
15
|
-
|
16
|
-
Nomo.exec
|
17
|
-
|
18
|
-
return_value
|
18
|
+
super
|
19
19
|
end
|
20
20
|
|
21
21
|
def cache_key
|
data/lib/nomo/page.rb
CHANGED
@@ -8,10 +8,6 @@ module Nomo
|
|
8
8
|
@options = options
|
9
9
|
end
|
10
10
|
|
11
|
-
def etag
|
12
|
-
@etag ||= Digest::MD5.hexdigest("#{key}/#{last_modified.to_f}")
|
13
|
-
end
|
14
|
-
|
15
11
|
def last_modified
|
16
12
|
if @last_modified.nil? && redis_last_modified = redis.get(key)
|
17
13
|
@last_modified = Time.at(redis_last_modified.to_f).utc
|
@@ -23,17 +19,16 @@ module Nomo
|
|
23
19
|
end
|
24
20
|
|
25
21
|
def modify(options = {})
|
26
|
-
@etag = nil
|
27
22
|
@last_modified = Time.now.utc
|
28
23
|
|
29
|
-
redis.set(key, last_modified.to_f)
|
30
24
|
Nomo.logger.debug("(nomo) key modified -- #{key}")
|
25
|
+
redis.set(key, last_modified.to_f)
|
31
26
|
|
32
27
|
Nomo.publish("updates", key) unless options[:publish].eql?(false) || !realtime?
|
33
28
|
end
|
34
29
|
|
35
30
|
def cache_key
|
36
|
-
"#{key}/#{
|
31
|
+
"#{key}/#{last_modified.to_f}"
|
37
32
|
end
|
38
33
|
|
39
34
|
def key
|
data/lib/nomo/version.rb
CHANGED
data/lib/nomo.rb
CHANGED
@@ -73,40 +73,37 @@ module Nomo
|
|
73
73
|
@logger || ::Rails.logger
|
74
74
|
end
|
75
75
|
|
76
|
-
@
|
76
|
+
@in_multi = false
|
77
77
|
@updates = []
|
78
78
|
|
79
79
|
def multi
|
80
|
-
|
81
|
-
|
80
|
+
unless @in_multi
|
81
|
+
@in_multi = true
|
82
|
+
|
82
83
|
Nomo.logger.debug("(nomo) Nomo.multi")
|
84
|
+
Nomo.redis.multi
|
83
85
|
end
|
84
|
-
|
85
|
-
@multi_count += 1
|
86
86
|
end
|
87
87
|
|
88
88
|
def exec
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
Nomo.logger.debug("(nomo) update published -- #{key}")
|
93
|
-
end
|
94
|
-
@updates = []
|
95
|
-
|
96
|
-
Nomo.redis.exec
|
97
|
-
Nomo.logger.debug("(nomo) Nomo.exec")
|
89
|
+
for key in @updates.uniq
|
90
|
+
Nomo.logger.debug("(nomo) update published -- #{key}")
|
91
|
+
Nomo.redis.publish("updates", key)
|
98
92
|
end
|
93
|
+
@updates = []
|
94
|
+
@in_multi = false
|
99
95
|
|
100
|
-
|
96
|
+
Nomo.logger.debug("(nomo) Nomo.exec")
|
97
|
+
Nomo.redis.exec
|
101
98
|
end
|
102
99
|
|
103
100
|
def publish(channel, msg)
|
104
|
-
if @
|
105
|
-
Nomo.redis.publish(channel, msg)
|
106
|
-
Nomo.logger.debug("(nomo) update published -- #{msg}")
|
107
|
-
else
|
108
|
-
@updates << msg
|
101
|
+
if @in_multi
|
109
102
|
Nomo.logger.debug("(nomo) update queued -- #{msg}")
|
103
|
+
@updates << msg
|
104
|
+
else
|
105
|
+
Nomo.logger.debug("(nomo) update published -- #{msg}")
|
106
|
+
Nomo.redis.publish(channel, msg)
|
110
107
|
end
|
111
108
|
end
|
112
109
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nomo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.38
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &70173080106580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70173080106580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis-namespace
|
27
|
-
requirement: &
|
27
|
+
requirement: &70173080106160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70173080106160
|
36
36
|
description: 304 Not Modified Headers made easy.
|
37
37
|
email:
|
38
38
|
- sausman@stackd.com
|