Module: Dnsruby::RR::GenericRegistryChanges
- Defined in:
- lib/dnsruby/resource/generic_cache.rb
Overview
User edits to the public registry invalidate automatic lookup entries. Native Hash operations above distinguish internal eviction from deletion.
Instance Method Summary collapse
-
#[]=(key, value) ⇒ Object
(also: #store)
:nodoc: all.
- #clear ⇒ Object
- #delete(key, &block) ⇒ Object
- #rehash ⇒ Object
- #replace(other) ⇒ Object
Instance Method Details
#[]=(key, value) ⇒ Object Also known as: store
:nodoc: all
295 296 297 298 299 300 301 302 |
# File 'lib/dnsruby/resource/generic_cache.rb', line 295 def []=(key, value) return super unless equal?(Dnsruby::ClassHash) && !frozen? pair = GenericCache.registry_pair(key) before = GenericCache.snapshot(pair) result = super GenericCache.register(before, pair, value) result end |
#clear ⇒ Object
314 315 316 317 318 319 320 321 |
# File 'lib/dnsruby/resource/generic_cache.rb', line 314 def clear return super unless equal?(Dnsruby::ClassHash) && !frozen? before = GenericCache.snapshot result = super GenericCache.forget(before) GenericCache.rehash result end |
#delete(key, &block) ⇒ Object
305 306 307 308 309 310 311 312 |
# File 'lib/dnsruby/resource/generic_cache.rb', line 305 def delete(key, &block) return super unless equal?(Dnsruby::ClassHash) && !frozen? pair = GenericCache.registry_pair(key) before = GenericCache.snapshot(pair) result = super GenericCache.forget(before, [pair], removed_only: true) result end |
#rehash ⇒ Object
338 339 340 341 342 |
# File 'lib/dnsruby/resource/generic_cache.rb', line 338 def rehash result = super GenericCache.rehash if equal?(Dnsruby::ClassHash) result end |
#replace(other) ⇒ Object
323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/dnsruby/resource/generic_cache.rb', line 323 def replace(other) return super unless equal?(Dnsruby::ClassHash) && !frozen? # Native conversion can call back into the factory. Snapshot afterwards # so entries returned by to_hash become explicit registrations too. replacement = {}.replace(other) before = GenericCache.snapshot result = super(replacement) replacement.each_pair do |key, value| GenericCache.register(before, GenericCache.registry_pair(key), value) end GenericCache.forget(before) GenericCache.rehash result end |