memcaches_page 0.1.3 → 0.2.0
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.
- data/CHANGELOG.md +12 -1
- data/README.md +12 -4
- data/lib/memcaches_page.rb +12 -3
- data/memcaches_page.gemspec +2 -2
- metadata +7 -7
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
# MemcachesPage Gem Changelog
|
2
2
|
|
3
|
-
## 0.
|
3
|
+
## 0.2.0 - 2013/03/11
|
4
|
+
* **Backwards-incompatible change**: Now called using `memcaches_page`. See
|
5
|
+
README for details.
|
6
|
+
* Update for compatibility with Rails 3.2
|
7
|
+
|
8
|
+
## 0.1.3 - 2012/09/20
|
9
|
+
* Allow passing through options to `Rails.cache.write`, e.g. `cache_page expires_in: 5.minutes`
|
10
|
+
|
11
|
+
## 0.1.2 - 2012/06/19
|
12
|
+
* Use standard Rails caching methods to reduce complexity
|
13
|
+
|
14
|
+
## 0.1.1 - 2012/06/19
|
4
15
|
* Still work with no namespace set
|
5
16
|
* Fail silently if Dalli isn't the store
|
6
17
|
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# MemcachesPage
|
2
2
|
|
3
|
-
Overrides `caches_page` and stores in memcached instead. Uses configuration from
|
3
|
+
Overrides `caches_page` and stores in memcached instead. Uses configuration from
|
4
|
+
Rails cache store.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
@@ -24,11 +25,12 @@ Or install it yourself as:
|
|
24
25
|
config.cache_store :dalli_store, ['memcache.dev:11211'], expires_in: 604800, namespace: "site"
|
25
26
|
```
|
26
27
|
|
27
|
-
Note, ensure compression isn't used, or if you do configure nginx to inflate it
|
28
|
+
Note, ensure compression isn't used, or if you do configure nginx to inflate it
|
29
|
+
before serving.
|
28
30
|
|
29
31
|
### Caching
|
30
32
|
|
31
|
-
|
33
|
+
Include the module in your `ApplicationController`:
|
32
34
|
|
33
35
|
```ruby
|
34
36
|
class ApplicationController < ActionController::Base
|
@@ -36,7 +38,13 @@ class ApplicationController < ActionController::Base
|
|
36
38
|
end
|
37
39
|
```
|
38
40
|
|
39
|
-
Then use `
|
41
|
+
Then use `memcaches_page` in a similar way to `caches_page`:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
class SiteController < ApplicationController
|
45
|
+
memcaches_page :index, :show, unless: -> { |c| c.current_user.nil? }
|
46
|
+
end
|
47
|
+
```
|
40
48
|
|
41
49
|
## Contributing
|
42
50
|
|
data/lib/memcaches_page.rb
CHANGED
@@ -1,15 +1,24 @@
|
|
1
1
|
module MemcachesPage
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
module ClassMethods
|
4
|
-
def
|
4
|
+
def memcaches_page(*actions)
|
5
|
+
return unless perform_caching
|
6
|
+
options = actions.extract_options!
|
7
|
+
|
8
|
+
after_filter({:only => actions}.merge(options)) do |c|
|
9
|
+
c.memcache_page
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def memcache_page(content, path, options={})
|
5
14
|
return unless perform_caching
|
6
15
|
|
7
16
|
Rails.cache.write path.gsub('%', '%25'), content, options.merge(raw: true)
|
8
17
|
end
|
9
18
|
end
|
10
19
|
|
11
|
-
def
|
20
|
+
def memcache_page(options = {})
|
12
21
|
return unless self.class.perform_caching && caching_allowed? && !request.params.key?('no-cache')
|
13
|
-
self.class.
|
22
|
+
self.class.memcache_page(response.body, request.fullpath, options)
|
14
23
|
end
|
15
24
|
end
|
data/memcaches_page.gemspec
CHANGED
@@ -6,12 +6,12 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.summary = %q{Uses configuration from Rails cache store.}
|
7
7
|
gem.homepage = ""
|
8
8
|
|
9
|
-
gem.add_dependency("rails", "~> 3.
|
9
|
+
gem.add_dependency("rails", "~> 3.2")
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
14
|
gem.name = "memcaches_page"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version = '0.
|
16
|
+
gem.version = '0.2.0'
|
17
17
|
end
|
metadata
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: memcaches_page
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.3
|
5
4
|
prerelease:
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Bowsher
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
15
|
+
prerelease: false
|
16
|
+
type: :runtime
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ~>
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version: '3.
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
22
|
+
version: '3.2'
|
24
23
|
version_requirements: !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
25
|
requirements:
|
27
26
|
- - ~>
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
version: '3.
|
28
|
+
version: '3.2'
|
29
|
+
name: rails
|
30
30
|
description: Overrides caches_page and stores in memcached instead.
|
31
31
|
email:
|
32
32
|
- pbowsher@globalpersonals.co.uk
|