Class: Rack::DevInsight::MemoryStore
- Inherits:
-
Object
- Object
- Rack::DevInsight::MemoryStore
- Defined in:
- lib/rack/dev_insight/storage/memory_store.rb
Constant Summary collapse
- MAX_REAP_SEC =
2
Instance Method Summary collapse
-
#initialize ⇒ MemoryStore
constructor
A new instance of MemoryStore.
- #read(id) ⇒ Object
- #write(result) ⇒ Object
Constructor Details
#initialize ⇒ MemoryStore
Returns a new instance of MemoryStore.
8 9 10 11 12 |
# File 'lib/rack/dev_insight/storage/memory_store.rb', line 8 def initialize @lock = Mutex.new @cache = {} @memory_size = DevInsight.config.memory_store_size end |
Instance Method Details
#read(id) ⇒ Object
21 22 23 |
# File 'lib/rack/dev_insight/storage/memory_store.rb', line 21 def read(id) @lock.synchronize { @cache[id] } end |
#write(result) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/rack/dev_insight/storage/memory_store.rb', line 14 def write(result) @lock.synchronize do @cache[result.id] = result reap_excess_memory end end |