Class: ESI::Tag::Invalidate
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#attributes, #cache, #children, #closed, #name
Instance Method Summary collapse
- #buffer(output, inner_html) ⇒ Object
- #close(output, options = {}) ⇒ Object
-
#initialize(uri, headers, http_params, name, attrs, cache) ⇒ Invalidate
constructor
A new instance of Invalidate.
Methods inherited from Base
Methods included from Log
#log, #log_debug, #log_error, #log_request, #msg
Constructor Details
#initialize(uri, headers, http_params, name, attrs, cache) ⇒ Invalidate
Returns a new instance of Invalidate.
10 11 12 13 |
# File 'lib/esi/tag/invalidate.rb', line 10 def initialize(uri,headers,http_params,name,attrs,cache) super @buffer = "" end |
Instance Method Details
#buffer(output, inner_html) ⇒ Object
50 51 52 53 |
# File 'lib/esi/tag/invalidate.rb', line 50 def buffer( output, inner_html ) # expects ^/<![CDATA[/ @buffer << inner_html end |
#close(output, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/esi/tag/invalidate.rb', line 14 def close( output, = {} ) xml = Hpricot.XML(@buffer) (xml/:OBJECT).each do|object| selector = (object % :BASICSELECTOR) advanced_selector = (object % :ADVANCEDSELECTOR) if selector action = (object % :ACTION) info = (object % :INFO) uri = selector[:URI] remove_ttl = action[:REMOVALTTL].to_i @cache.keys do |key,fragment| if fragment.uri.match(uri) @cache.delete_unlocked( key ) end end elsif advanced_selector # XXX: this code is untested! # NOTE: our support of both advanced and basic is a little off # we'll probably invalidate more then is normally done by the standard # also when we switch to memcache this will be much harder to support this flexibilty uri_prefix = advanced_selector[:URIPREFIX] uri_regex = advanced_selector[:URIEXP] @cache.keys do |key,data| if key.match(uri_prefix) and key.match(uri_regex) puts "invalidating #{uri}" # XXX: this code is untested! @cache.delete_unlocked( key, remove_ttl ) end end # XXX: this code is untested! end end @cache.sweep! end |