cacher 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/cacher.rb +26 -1
  2. data/lib/cacher/version.rb +1 -1
  3. metadata +2 -8
@@ -90,6 +90,31 @@ module Cacher
90
90
  @enabled = false
91
91
  end
92
92
 
93
+ def bust!
94
+ bust_hash[object_id] = true
95
+ if block_given?
96
+ begin
97
+ yield
98
+ ensure
99
+ unbust!
100
+ end
101
+ end
102
+ end
103
+
104
+ def unbust!
105
+ bust_hash[object_id] = false
106
+ end
107
+
108
+ def busting?
109
+ !!bust_hash[object_id]
110
+ end
111
+
112
+ private
113
+ def bust_hash
114
+ Thread.current[:cacher_bust_hash] ||= {}
115
+ end
116
+ public
117
+
93
118
  def enabled?
94
119
  return @enabled if instance_variable_defined? :@enabled
95
120
  @enabled = Cacher.enabled?
@@ -108,7 +133,7 @@ module Cacher
108
133
  end
109
134
 
110
135
  def get(key, options={}, &blk)
111
- return set(key, options, &blk) if options.delete(:break)
136
+ return set(key, options, &blk) if options.delete(:break) || busting?
112
137
 
113
138
  cached = cache_get(key)
114
139
 
@@ -1,5 +1,5 @@
1
1
  module Cacher
2
2
  def self.version
3
- '0.1.0'
3
+ '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cacher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-09 00:00:00.000000000Z
12
+ date: 2012-02-24 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: A nifty configurable frontend to any cache
15
15
  email:
@@ -34,18 +34,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
34
34
  - - ! '>='
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
- segments:
38
- - 0
39
- hash: 1321207108986446288
40
37
  required_rubygems_version: !ruby/object:Gem::Requirement
41
38
  none: false
42
39
  requirements:
43
40
  - - ! '>='
44
41
  - !ruby/object:Gem::Version
45
42
  version: '0'
46
- segments:
47
- - 0
48
- hash: 1321207108986446288
49
43
  requirements: []
50
44
  rubyforge_project: cacher
51
45
  rubygems_version: 1.8.10