cachai 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cachai.gemspec +1 -1
- data/lib/cachai.rb +8 -6
- data/lib/models.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 234339e799e8d9dcf93b45c1c9263a99cc1ff02c
|
4
|
+
data.tar.gz: 98ad064f8d146f20e974855ad269ef99c4b24c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20bfee40c5964d4e8df84e2e349028d17a8b12684841376654a4967d5f814b99379973dcc9457b1e9eca65208ce7829f49ad4b42d72b15e04219cbf4e7d22c42
|
7
|
+
data.tar.gz: e7f6c090387caa5a6450a07d288c120d8ce4e0d4250a62d44a6aa037319d5384627c3c3239c83dd07cd841bae4a5a786705cf3ca083af026f22faafbb6ebb135
|
data/cachai.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "cachai"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.4'
|
8
8
|
spec.authors = ["Tomás Pollak"]
|
9
9
|
spec.email = ["tomas@forkhq.com"]
|
10
10
|
spec.description = %q{Middleware for embedabble comments.}
|
data/lib/cachai.rb
CHANGED
@@ -80,7 +80,7 @@ module Cachai
|
|
80
80
|
:author_ip => request.ip
|
81
81
|
}
|
82
82
|
|
83
|
-
post = Post.
|
83
|
+
post = Post.find_or_create_by_path(data['path'])
|
84
84
|
response = Response.create!(attrs.merge(:post_id => post.id))
|
85
85
|
|
86
86
|
@redis.del(redis_key(data['path']))
|
@@ -123,8 +123,13 @@ module Cachai
|
|
123
123
|
key = redis_key(path)
|
124
124
|
unless json_list = @redis.get(key)
|
125
125
|
puts "Not cached. Getting from DB: #{path}"
|
126
|
-
|
127
|
-
|
126
|
+
|
127
|
+
if post = Post.find_by_path(path)
|
128
|
+
json_list = get_and_sort_comments_for(post).to_json
|
129
|
+
else
|
130
|
+
json_list = '[]'
|
131
|
+
end
|
132
|
+
|
128
133
|
@redis.set(key, json_list)
|
129
134
|
@redis.expire(key, 60 * 60) # one hour
|
130
135
|
end
|
@@ -136,9 +141,6 @@ module Cachai
|
|
136
141
|
top_level = post.responses.comment.top_level
|
137
142
|
nested = post.responses.comment.nested
|
138
143
|
|
139
|
-
puts top_level.count
|
140
|
-
puts nested.count
|
141
|
-
|
142
144
|
top_level.each_with_index do |comment, i|
|
143
145
|
obj = comment.as_json
|
144
146
|
children = nested.select do |nested|
|
data/lib/models.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cachai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomás Pollak
|
@@ -148,9 +148,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.2.0
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Middleware for embedabble comments.
|
155
155
|
test_files:
|
156
156
|
- test/app_test.rb
|
157
|
+
has_rdoc:
|