Class | Webgen::Cache |
In: |
lib/webgen/cache.rb
|
Parent: | Object |
A cache object provides access to various caches to speed up rendering of a website:
The standard cache should be accessed through the [] method which returns the correct value and the []= method should be used for setting the new value. However, if you really need to access a particular value of the old or new standard cache, you can use the accessors old_data and new_data.
new_data | [R] | The cache data stored in the current webgen run. |
old_data | [R] | The cache data stored in the previous webgen run. |
permanent | [R] | The permanent cache hash. |
volatile | [R] | The volatile cache hash. |
Store value identified by key in the standard cache.
# File lib/webgen/cache.rb, line 57 57: def []=(key, value) 58: @new_data[key] = value 59: end
Return all caches that should be available between webgen runs.
# File lib/webgen/cache.rb, line 68 68: def dump 69: [@old_data.merge(@new_data), @permanent] 70: end
Return the unique instance of the class name (a String). This method should be used when it is essential that webgen uses only one object of a class or when an object should automatically be recreated upon cache restoration (see restore).
# File lib/webgen/cache.rb, line 80 80: def instance(name) 81: @permanent[:classes] << name unless @permanent[:classes].include?(name) 82: (@volatile[:classes] ||= {})[name] ||= Common.const_for_name(name).new 83: end
Reset the volatile cache.
# File lib/webgen/cache.rb, line 73 73: def reset_volatile_cache 74: @volatile = {:classes => @volatile[:classes]} 75: end