grape-rails-cache 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cf9010721ffbc4bba100223ecf6680073ac2336
4
- data.tar.gz: 898a459110b5521b9829be56e56e5a4f7c9dae18
3
+ metadata.gz: c606eb3c07de22f542487e53f8b90fbd45cc60ab
4
+ data.tar.gz: 8c656e986a358c457b907b307ed253d77f1f7e81
5
5
  SHA512:
6
- metadata.gz: ebef843153d47923866360da8b416b1dff79421d265b29e300fdd836a6aee28ace85447ef31a45ced8dff058256aae3c179db6200cab3036d2a1b4111192be20
7
- data.tar.gz: bb976a2490ff7e435a601175bfa1557427263076474cb6550784b29add88671a5c2ad319e61892bcb286c4e4d6817e3c428dae522efe1abb1632c5b8a7eb8e52
6
+ metadata.gz: be8284046f2812679f272e98501d4b8252f806ebdad96d4d6e195fe1c9cc0d07567631d9b94604ce6470caf7e9183f9b5acf00edd3cc1c837038838876d95a62
7
+ data.tar.gz: c48adc75c73dd554bb33e2be2b03bf69998fd9a2c43e324eac66e8fee7da27b8dc5c99e2d90090f15ece417f325c9f455ee938116159e0dec1db4f081923f9d7
data/README.md CHANGED
@@ -10,11 +10,15 @@
10
10
 
11
11
  Add this line to your rails application's Gemfile:
12
12
 
13
- gem 'grape-rails-cache'
13
+ ```ruby
14
+ gem 'grape-rails-cache'
15
+ ```
14
16
 
15
17
  And then execute:
16
18
 
17
- $ bundle
19
+ ```bash
20
+ $ bundle
21
+ ```
18
22
 
19
23
  ## Usage
20
24
 
@@ -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
- cache_control << "max-age=#{seconds}"
24
- cache_control.delete("no-cache")
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
- ::Rails.cache.fetch(cache_key, raw: true, expires_in: opts[:expires_in]) do
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
@@ -1,7 +1,7 @@
1
1
  module Grape
2
2
  module Rails
3
3
  module Cache
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  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.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-03-07 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grape