scoped_cache_keys 0.1.0 → 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b96bac82675a12d0d185510840185d0829a897d4f08242ccf94922cfa45d1afd
4
+ data.tar.gz: 87efd06a51cf71fb41d3b8193ed8f5f56378951101c8ffa341910e82e26c2386
5
+ SHA512:
6
+ metadata.gz: a62968c83bfddb74ad349eaf0865700e65186bbc28bdcfdefbf156dfb00956e2b611ff0a2f5c4ca9b92653fb0442b2f99f91ef6908b33cf6bef7f035b941e96d
7
+ data.tar.gz: 3eb0de9f214f5855fc0d21cd3bbe1b8e504f68d428f92902ffbd6ea96895d12990cc275087e14eefc24fd595f5bb593fada8c27c8d1c676c3b91c350d612b90c
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .ruby-version
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
+
2
3
  gemspec
3
4
 
4
5
  gem 'rake'
data/Gemfile.lock CHANGED
@@ -1,39 +1,41 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scoped_cache_keys (0.1.0)
4
+ scoped_cache_keys (0.2.0)
5
5
 
6
6
  GEM
7
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
8
8
  specs:
9
- activemodel (3.2.3)
10
- activesupport (= 3.2.3)
11
- builder (~> 3.0.0)
12
- activerecord (3.2.3)
13
- activemodel (= 3.2.3)
14
- activesupport (= 3.2.3)
15
- arel (~> 3.0.2)
16
- tzinfo (~> 0.3.29)
17
- activesupport (3.2.3)
18
- i18n (~> 0.6)
19
- multi_json (~> 1.0)
20
- arel (3.0.2)
21
- builder (3.0.0)
22
- diff-lcs (1.1.3)
23
- i18n (0.6.0)
24
- multi_json (1.3.4)
25
- rake (0.9.2)
26
- rspec (2.6.0)
27
- rspec-core (~> 2.6.0)
28
- rspec-expectations (~> 2.6.0)
29
- rspec-mocks (~> 2.6.0)
30
- rspec-core (2.6.4)
31
- rspec-expectations (2.6.0)
32
- diff-lcs (~> 1.1.2)
33
- rspec-mocks (2.6.0)
34
- sqlite3 (1.3.6)
35
- timecop (0.3.5)
36
- tzinfo (0.3.33)
9
+ activemodel (7.0.4)
10
+ activesupport (= 7.0.4)
11
+ activerecord (7.0.4)
12
+ activemodel (= 7.0.4)
13
+ activesupport (= 7.0.4)
14
+ activesupport (7.0.4)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 1.6, < 2)
17
+ minitest (>= 5.1)
18
+ tzinfo (~> 2.0)
19
+ concurrent-ruby (1.1.10)
20
+ diff-lcs (1.5.0)
21
+ i18n (1.12.0)
22
+ concurrent-ruby (~> 1.0)
23
+ mini_portile2 (2.8.0)
24
+ minitest (5.16.3)
25
+ rake (13.0.6)
26
+ rspec (2.99.0)
27
+ rspec-core (~> 2.99.0)
28
+ rspec-expectations (~> 2.99.0)
29
+ rspec-mocks (~> 2.99.0)
30
+ rspec-core (2.99.2)
31
+ rspec-expectations (2.99.2)
32
+ diff-lcs (>= 1.1.3, < 2.0)
33
+ rspec-mocks (2.99.4)
34
+ sqlite3 (1.5.3)
35
+ mini_portile2 (~> 2.8.0)
36
+ timecop (0.9.5)
37
+ tzinfo (2.0.5)
38
+ concurrent-ruby (~> 1.0)
37
39
 
38
40
  PLATFORMS
39
41
  ruby
@@ -45,3 +47,6 @@ DEPENDENCIES
45
47
  scoped_cache_keys!
46
48
  sqlite3
47
49
  timecop
50
+
51
+ BUNDLED WITH
52
+ 2.3.12
data/Readme.md CHANGED
@@ -2,24 +2,27 @@ Add scoped_cache_key / expire_scoped_cache_key to your models for caching/sweepi
2
2
 
3
3
  Install
4
4
  =======
5
- sudo gem install scoped_cache_keys
6
- Or
7
5
 
8
- rails plugin install git://github.com/grosser/scoped_cache_keys.git
6
+ ```bash
7
+ gem "scoped_cache_keys"
8
+ ```
9
9
 
10
10
  Usage
11
11
  =====
12
12
 
13
13
  Gives you a key that will change whenever expire_scoped_cache_key is called.
14
14
 
15
+ ```
15
16
  <% cache user.scoped_cache_key :products do %>
16
17
  ... user.products.each ...
17
18
  <% end %>
18
19
 
19
- <% cache "something-else-" + user.scoped_cache_key :products %>
20
+ <% cache "something-else-" + user.scoped_cache_key(:products) do %>
20
21
  ... will also be expired ...
21
22
  <% end %>
23
+ ```
22
24
 
25
+ ```ruby
23
26
  # app/sweepers/product_sweeper.rb
24
27
  class ProductSweeper < ActionController::Caching::Sweeper
25
28
  observe Product
@@ -28,10 +31,10 @@ Gives you a key that will change whenever expire_scoped_cache_key is called.
28
31
  record.user.expire_scoped_cache_key :products
29
32
  end
30
33
  end
34
+ ```
31
35
 
32
36
  Author
33
37
  ======
34
38
  [Zendesk](http://zendesk.com)<br/>
35
39
  michael@grosser.it<br/>
36
- License: MIT<br/>
37
- [![Build Status](https://secure.travis-ci.org/grosser/scoped_cache_keys.png)](http://travis-ci.org/grosser/scoped_cache_keys)
40
+ License: MIT
@@ -1,3 +1,3 @@
1
1
  module ScopedCacheKeys
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,8 +1,8 @@
1
1
  require 'scoped_cache_keys/version'
2
2
 
3
3
  module ScopedCacheKeys
4
- def scoped_cache_key(scope)
5
- base_key = Rails.cache.fetch(build_scoped_cache_key([scope])){ Time.now.to_f }
4
+ def scoped_cache_key(scope, options = nil)
5
+ base_key = Rails.cache.fetch(build_scoped_cache_key([scope]), options) { Time.now.to_f }
6
6
  build_scoped_cache_key [scope, base_key]
7
7
  end
8
8
 
@@ -10,11 +10,6 @@ module ScopedCacheKeys
10
10
  Rails.cache.delete(build_scoped_cache_key(scope))
11
11
  end
12
12
 
13
- def touch_if_necessary
14
- raise "#{self.class} has no updated_at" unless respond_to? :updated_at=
15
- touch if updated_at < 1.second.ago
16
- end
17
-
18
13
  private
19
14
 
20
15
  def build_scoped_cache_key(*scopes)
@@ -60,38 +60,4 @@ describe ScopedCacheKeys do
60
60
  }.to_not change{ user.scoped_cache_key(:foo) }
61
61
  end
62
62
  end
63
-
64
- describe "#touch_if_necessary" do
65
- context "with a model that has updated_at" do
66
- let(:model) do
67
- user = User.create!
68
- user.update_attribute(:updated_at, 1.month.ago)
69
- user
70
- end
71
-
72
- it "increments updated_at" do
73
- expect{
74
- model.touch_if_necessary
75
- }.to change{ model.reload.updated_at.to_i }
76
- end
77
-
78
- it "does not update updated_at if it thinks the model is fresh" do
79
- model.touch_if_necessary
80
- expect{
81
- model.class.update(model.id, :updated_at => 1.month.ago)
82
- model.touch_if_necessary
83
- }.to change{ model.reload.updated_at.to_i }
84
- end
85
- end
86
-
87
- context "with a model that does not have updated_at" do
88
- let(:model){ Product.create! }
89
-
90
- it "raises" do
91
- expect{
92
- model.touch_if_necessary
93
- }.to raise_error
94
- end
95
- end
96
- end
97
63
  end
metadata CHANGED
@@ -1,33 +1,22 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: scoped_cache_keys
3
- version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 0
10
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Michael Grosser
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2012-05-04 00:00:00 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
19
12
  dependencies: []
20
-
21
13
  description:
22
14
  email: michael@grosser.it
23
15
  executables: []
24
-
25
16
  extensions: []
26
-
27
17
  extra_rdoc_files: []
28
-
29
- files:
30
- - .travis.yml
18
+ files:
19
+ - ".gitignore"
31
20
  - Gemfile
32
21
  - Gemfile.lock
33
22
  - Rakefile
@@ -38,37 +27,27 @@ files:
38
27
  - spec/scoped_cache_keys_spec.rb
39
28
  - spec/spec_helper.rb
40
29
  homepage: http://github.com/grosser/scoped_cache_keys
41
- licenses:
30
+ licenses:
42
31
  - MIT
32
+ metadata: {}
43
33
  post_install_message:
44
34
  rdoc_options: []
45
-
46
- require_paths:
35
+ require_paths:
47
36
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
51
39
  - - ">="
52
- - !ruby/object:Gem::Version
53
- hash: 3
54
- segments:
55
- - 0
56
- version: "0"
57
- required_rubygems_version: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
60
44
  - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
66
47
  requirements: []
67
-
68
- rubyforge_project:
69
- rubygems_version: 1.8.24
48
+ rubygems_version: 3.1.6
70
49
  signing_key:
71
- specification_version: 3
72
- summary: Add scoped_cache_key / expire_scoped_cache_key to your models for caching/sweeping of model-related caches + touch_if_necessary
50
+ specification_version: 4
51
+ summary: Add scoped_cache_key / expire_scoped_cache_key to your models for caching/sweeping
52
+ of model-related caches + touch_if_necessary
73
53
  test_files: []
74
-
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- script: "bundle exec rake"
2
- rvm:
3
- - ree
4
- - 1.9.2
5
- - 1.9.3