nomo 0.0.32 → 0.0.33
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 +6 -6
- data/lib/nomo/page.rb +12 -6
- data/lib/nomo/version.rb +1 -1
- data/lib/nomo.rb +19 -2
- metadata +6 -6
data/lib/nomo/conditional_get.rb
CHANGED
@@ -7,7 +7,7 @@ module Nomo
|
|
7
7
|
nomo_page = record_or_options
|
8
8
|
|
9
9
|
record_or_options = { etag: nomo_page.etag,
|
10
|
-
last_modified:
|
10
|
+
last_modified: nomo_page.last_modified }
|
11
11
|
|
12
12
|
response.headers['Nomo-Key'] = nomo_page.key if nomo_page.realtime?
|
13
13
|
end
|
data/lib/nomo/model.rb
CHANGED
@@ -38,8 +38,8 @@ module Nomo
|
|
38
38
|
page.modify
|
39
39
|
end
|
40
40
|
|
41
|
-
after_update modify_page_method, options.fetch(:
|
42
|
-
after_touch modify_page_method, options.fetch(:
|
41
|
+
after_update modify_page_method, options.fetch(:update, {}) unless options.has_key?(:on) && !options[:on].include?(:update)
|
42
|
+
after_touch modify_page_method, options.fetch(:touch, {}) unless options.has_key?(:on) && !options[:on].include?(:touch)
|
43
43
|
end
|
44
44
|
|
45
45
|
def modifies(association, name, options = {})
|
@@ -52,10 +52,10 @@ module Nomo
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
after_create modify_page_method, options.fetch(:
|
56
|
-
after_update modify_page_method, options.fetch(:
|
57
|
-
after_destroy modify_page_method, options.fetch(:
|
58
|
-
after_touch modify_page_method, options.fetch(:
|
55
|
+
after_create modify_page_method, options.fetch(:create, {}) unless options.has_key?(:on) && !options[:on].include?(:create)
|
56
|
+
after_update modify_page_method, options.fetch(:update, {}) unless options.has_key?(:on) && !options[:on].include?(:update)
|
57
|
+
after_destroy modify_page_method, options.fetch(:destroy, {}) unless options.has_key?(:on) && !options[:on].include?(:destroy)
|
58
|
+
after_touch modify_page_method, options.fetch(:touch, {}) unless options.has_key?(:on) && !options[:on].include?(:touch)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/lib/nomo/page.rb
CHANGED
@@ -14,7 +14,7 @@ module Nomo
|
|
14
14
|
|
15
15
|
def last_modified
|
16
16
|
if @last_modified.nil? && redis_last_modified = redis.get(key)
|
17
|
-
@last_modified = redis_last_modified
|
17
|
+
@last_modified = redis_value_to_time(redis_last_modified)
|
18
18
|
elsif @last_modified.nil?
|
19
19
|
modify(publish: false)
|
20
20
|
end
|
@@ -24,12 +24,10 @@ module Nomo
|
|
24
24
|
|
25
25
|
def modify(options = {})
|
26
26
|
@etag = nil
|
27
|
-
@last_modified = Time.now.
|
27
|
+
@last_modified = Time.now.utc
|
28
28
|
|
29
|
-
redis.set(key, last_modified)
|
30
|
-
|
31
|
-
|
32
|
-
logger.debug("(nomo) #{key} modified -- #{last_modified}")
|
29
|
+
redis.set(key, time_to_redis_value(last_modified))
|
30
|
+
Nomo.publish_update(key) unless options[:publish].eql?(false) || !realtime?
|
33
31
|
end
|
34
32
|
|
35
33
|
def cache_key
|
@@ -55,5 +53,13 @@ module Nomo
|
|
55
53
|
def logger
|
56
54
|
Nomo.logger
|
57
55
|
end
|
56
|
+
|
57
|
+
def time_to_redis_value(time)
|
58
|
+
time.to_f.to_s
|
59
|
+
end
|
60
|
+
|
61
|
+
def redis_value_to_time(redis_value)
|
62
|
+
Time.at(redis_value.to_f).utc
|
63
|
+
end
|
58
64
|
end
|
59
65
|
end
|
data/lib/nomo/version.rb
CHANGED
data/lib/nomo.rb
CHANGED
@@ -73,9 +73,10 @@ module Nomo
|
|
73
73
|
@logger || ::Rails.logger
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
76
|
+
@redis_multi_count = 0
|
77
|
+
@redis_updates = []
|
78
78
|
|
79
|
+
def redis_multi
|
79
80
|
if @redis_multi_count == 0
|
80
81
|
Nomo.redis.multi
|
81
82
|
Nomo.logger.debug("(nomo) redis.multi")
|
@@ -86,10 +87,26 @@ module Nomo
|
|
86
87
|
|
87
88
|
def redis_exec
|
88
89
|
if @redis_multi_count == 1
|
90
|
+
for key in @redis_updates.uniq
|
91
|
+
Nomo.redis.publish("updates", key)
|
92
|
+
Nomo.logger.debug("(nomo) update published -- #{key} [Nomo.redis_exec]")
|
93
|
+
end
|
94
|
+
@redis_updates = []
|
95
|
+
|
89
96
|
Nomo.redis.exec
|
90
97
|
Nomo.logger.debug("(nomo) redis.exec")
|
91
98
|
end
|
92
99
|
|
93
100
|
@redis_multi_count -= 1
|
94
101
|
end
|
102
|
+
|
103
|
+
def publish_update(key)
|
104
|
+
if @redis_multi_count == 0
|
105
|
+
Nomo.redis.publish("updates", key)
|
106
|
+
Nomo.logger.debug("(nomo) update published -- #{key} [Nomo.publish_update]")
|
107
|
+
else
|
108
|
+
@redis_updates << key
|
109
|
+
Nomo.logger.debug("(nomo) update queued -- #{key} [Nomo.publish_update]")
|
110
|
+
end
|
111
|
+
end
|
95
112
|
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.33
|
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-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis
|
16
|
-
requirement: &
|
16
|
+
requirement: &70112842321420 !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: *70112842321420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: redis-namespace
|
27
|
-
requirement: &
|
27
|
+
requirement: &70112842321000 !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: *70112842321000
|
36
36
|
description: 304 Not Modified Headers made easy.
|
37
37
|
email:
|
38
38
|
- sausman@stackd.com
|