Class: LRU
- Inherits:
-
Hash
- Object
- Hash
- LRU
- Defined in:
- lib/rabl/cache_engine.rb
Overview
Defines the default cache engine for RABL when caching is invoked for a template. You can define your own caching engines by creating an object that responds to fetch and setting the configuration option:
config.cache_engine = AdvancedCacheEngine.new
Instance Attribute Summary collapse
-
#max_size ⇒ Object
Returns the value of attribute max_size.
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
-
#initialize ⇒ LRU
constructor
A new instance of LRU.
- #limit_size ⇒ Object
Constructor Details
#initialize ⇒ LRU
Returns a new instance of LRU.
11 12 13 14 |
# File 'lib/rabl/cache_engine.rb', line 11 def initialize super self.max_size = 100_000 end |
Instance Attribute Details
#max_size ⇒ Object
Returns the value of attribute max_size.
9 10 11 |
# File 'lib/rabl/cache_engine.rb', line 9 def max_size @max_size end |
Instance Method Details
#[]=(k, v) ⇒ Object
16 17 18 19 20 |
# File 'lib/rabl/cache_engine.rb', line 16 def []= k,v r = super limit_size r end |
#limit_size ⇒ Object
22 23 24 25 26 |
# File 'lib/rabl/cache_engine.rb', line 22 def limit_size if size > max_size then delete keys.shift while size > max_size end end |