cache_method 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjczZDg5NDE3MTY2MGMxMTMwNGI3OWFhOTZhMGM1NzE5YTQzZDkzYQ==
5
- data.tar.gz: !binary |-
6
- OGZhNzRiM2JhMTQ3NjA3MzllOTc0NDEyOGZlZGI5OTg4MWNkYTM4MA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NmQ1MTIxOTJkZTZjZjFjODRlMDM5MjNmOGU0N2YwN2M0NzIwYWEwYzAyMTAw
10
- YTM2MDAwMGI0OWZhZmVlOWE5ODY2ZjhhZjlkNGE5MTliYmFjNTU1YzA2MjA3
11
- YWM3YWFhODY1MTBiMGFmNWI5YmIxOTc3MWQ2MmM2YmRlNjYxOTI=
12
- data.tar.gz: !binary |-
13
- NTQ5ZDBkYjViNGIxYjk0MDE4MTY0ZGRmNTFlNTI0NTcwMDFiN2NmZmZmNThk
14
- ODdlYWVkNDcyZjlmODVjNTNjYzI1OGUzNjJiNDg2YjhjZDIxODc2ODhlYzg5
15
- YzUzZDMzNmIzNmNkNWQyNGEyMTA5OWFjNzU4MGU4ZjhhODViOTE=
2
+ SHA1:
3
+ metadata.gz: 8b8d20b99b7ba8067404102bc6798f89758e7cf1
4
+ data.tar.gz: 90a972d5f72d67f095f16736f6166d3eb9d34cbd
5
+ SHA512:
6
+ metadata.gz: 5f7b2c514703e9d6ae939e8fb8e70a6b56f849de1762fb2672a477a8e490cd9bd874aefc7c20a7dfed7bb3be9399795f67749052cbee19f52df1878a8a3fcd67
7
+ data.tar.gz: 03978fa877cfaaefdc50fa1aa48392b864ad2ca8e34cd3769da7c01c20cd1e8d46e4638769fd2ed18408e30ee20985b86c1c79722049f867a5650c24fc026118
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.2.7 / 2015-04-03
2
+
3
+ * Enhancements
4
+
5
+ * CacheMethod.config.default_generational_ttl so that generations can expire - thanks @itspriddle https://github.com/seamusabshere/cache_method/pull/10
6
+
1
7
  0.2.6 / 2013-05-13
2
8
 
3
9
  * Enhancements
@@ -197,6 +197,10 @@ You can disable it to get a little speed boost
197
197
 
198
198
  CacheMethod.config.generational = false
199
199
 
200
+ Generational caching stores a separate generation key that never expires by default. To set a default TTL for these
201
+
202
+ CacheMethod.config.default_generational_ttl = 120
203
+
200
204
  ## Debug
201
205
 
202
206
  CacheMethod can warn you if your obj or args cache keys are suspiciously long.
@@ -93,7 +93,7 @@ module CacheMethod
93
93
  # cache_method :get_latest_entries
94
94
  # end
95
95
  def cache_method(method_id, ttl = nil)
96
- original_method_id = "_uncached_#{method_id}"
96
+ original_method_id = "_cache_method_#{method_id}"
97
97
  alias_method original_method_id, method_id
98
98
  define_method method_id do |*args, &blk|
99
99
  ::CacheMethod::CachedResult.new(self, method_id, original_method_id, ttl, args, &blk).fetch
@@ -115,7 +115,7 @@ module CacheMethod
115
115
  # cache_method_clear_on :update_entries, :get_latest_entries
116
116
  # end
117
117
  def cache_method_clear_on(method_id, cache_method_clear_id)
118
- original_method_id = "_original_#{method_id}"
118
+ original_method_id = "_cache_method_clear_on_#{method_id}"
119
119
  alias_method original_method_id, method_id
120
120
 
121
121
  define_method method_id do |*args, &blk|
@@ -63,5 +63,17 @@ module CacheMethod
63
63
  def default_ttl #:nodoc:
64
64
  @default_ttl || 86_400
65
65
  end
66
+
67
+ # TTL for method generational caches. Defaults to 0 (never).
68
+ #
69
+ # Example:
70
+ # CacheMethod.config.default_generational_ttl = 120 # seconds
71
+ def default_generational_ttl=(seconds)
72
+ @default_generational_ttl = seconds
73
+ end
74
+
75
+ def default_generational_ttl #:nodoc:
76
+ @default_generational_ttl || 0
77
+ end
66
78
  end
67
79
  end
@@ -41,8 +41,7 @@ module CacheMethod
41
41
 
42
42
  def set
43
43
  random_name = ::Kernel.rand(1e11).to_s
44
- # never expire!
45
- CacheMethod.config.storage.set cache_key, random_name, 0
44
+ CacheMethod.config.storage.set cache_key, random_name, CacheMethod.config.default_generational_ttl
46
45
  random_name
47
46
  end
48
47
  end
@@ -1,3 +1,3 @@
1
1
  module CacheMethod
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_method
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-13 00:00:00.000000000 Z
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cache
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dalli
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: minitest-reporters
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  description: Like alias_method, but it's cache_method!
@@ -101,7 +101,7 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - .gitignore
104
+ - ".gitignore"
105
105
  - CHANGELOG
106
106
  - Gemfile
107
107
  - README.markdown
@@ -124,17 +124,17 @@ require_paths:
124
124
  - lib
125
125
  required_ruby_version: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ! '>='
127
+ - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
- - - ! '>='
132
+ - - ">="
133
133
  - !ruby/object:Gem::Version
134
134
  version: '0'
135
135
  requirements: []
136
136
  rubyforge_project: cache_method
137
- rubygems_version: 2.0.3
137
+ rubygems_version: 2.2.2
138
138
  signing_key:
139
139
  specification_version: 4
140
140
  summary: Lets you cache methods (to memcached, redis, etc.) sort of like you can memoize