Class: RProxy::CachePool
- Inherits:
-
Object
- Object
- RProxy::CachePool
- Defined in:
- lib/r_proxy/cache_pool.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #disable_write! ⇒ Object
- #enable_write! ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ CachePool
constructor
A new instance of CachePool.
- #writable? ⇒ Boolean
Constructor Details
#initialize ⇒ CachePool
Returns a new instance of CachePool.
4 5 6 7 |
# File 'lib/r_proxy/cache_pool.rb', line 4 def initialize @pool = {} @able_write = true end |
Instance Method Details
#[](key) ⇒ Object
15 16 17 |
# File 'lib/r_proxy/cache_pool.rb', line 15 def [](key) @pool[key] end |
#[]=(key, value) ⇒ Object
9 10 11 12 |
# File 'lib/r_proxy/cache_pool.rb', line 9 def []=(key, value) return value if !@able_write @pool[key] = value end |
#disable_write! ⇒ Object
23 24 25 |
# File 'lib/r_proxy/cache_pool.rb', line 23 def disable_write! @able_write = false end |
#enable_write! ⇒ Object
27 28 29 |
# File 'lib/r_proxy/cache_pool.rb', line 27 def enable_write! @able_write = true end |
#flush ⇒ Object
31 32 33 34 35 |
# File 'lib/r_proxy/cache_pool.rb', line 31 def flush tmp = @pool @pool = {} tmp end |
#writable? ⇒ Boolean
19 20 21 |
# File 'lib/r_proxy/cache_pool.rb', line 19 def writable? @able_write end |