grape-rails-cache 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/grape/rails/cache.rb +7 -4
- data/lib/grape/rails/cache/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c606eb3c07de22f542487e53f8b90fbd45cc60ab
|
4
|
+
data.tar.gz: 8c656e986a358c457b907b307ed253d77f1f7e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be8284046f2812679f272e98501d4b8252f806ebdad96d4d6e195fe1c9cc0d07567631d9b94604ce6470caf7e9183f9b5acf00edd3cc1c837038838876d95a62
|
7
|
+
data.tar.gz: c48adc75c73dd554bb33e2be2b03bf69998fd9a2c43e324eac66e8fee7da27b8dc5c99e2d90090f15ece417f325c9f455ee938116159e0dec1db4f081923f9d7
|
data/README.md
CHANGED
data/lib/grape/rails/cache.rb
CHANGED
@@ -20,10 +20,12 @@ module Grape
|
|
20
20
|
# Based on actionpack/lib/action_controller/base.rb, line 1216
|
21
21
|
def expires_in(seconds, options = {})
|
22
22
|
cache_control = []
|
23
|
-
|
24
|
-
|
23
|
+
if seconds == 0
|
24
|
+
cache_control << "no-cache"
|
25
|
+
else
|
26
|
+
cache_control << "max-age=#{seconds}"
|
27
|
+
end
|
25
28
|
if options[:public]
|
26
|
-
cache_control.delete("private")
|
27
29
|
cache_control << "public"
|
28
30
|
else
|
29
31
|
cache_control << "private"
|
@@ -52,7 +54,8 @@ module Grape
|
|
52
54
|
end
|
53
55
|
|
54
56
|
# Try to fetch from server side cache
|
55
|
-
|
57
|
+
cache_store_expire_time = opts[:cache_store_expires_in] || opts[:expires_in] || default_expire_time
|
58
|
+
::Rails.cache.fetch(cache_key, raw: true, expires_in: cache_store_expire_time) do
|
56
59
|
block.call.to_json
|
57
60
|
end
|
58
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-rails-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|