# File Ruby/lib/mini_profiler/storage/memory_store.rb, line 7 def initialize(args) @timer_struct_lock = Mutex.new @timer_struct_cache = {} @user_view_lock = Mutex.new @user_view_cache = {} # TODO: fix it to use weak ref, trouble is may be broken in 1.9 so need to use the 'ref' gem me = self Thread.new do while true do me.cleanup_cache sleep(3600) end end end
# File Ruby/lib/mini_profiler/storage/memory_store.rb, line 55 def cleanup_cache expire_older_than = ((Time.now.to_f - MiniProfiler::MemoryStore::EXPIRE_TIMER_CACHE) * 1000).to_i @timer_struct_lock.synchronize { @timer_struct_cache.delete_if { |k, v| v['Started'] < expire_older_than } } end
# File Ruby/lib/mini_profiler/storage/memory_store.rb, line 49 def get_unviewed_ids(user) @user_view_lock.synchronize { @user_view_cache[user] } end
# File Ruby/lib/mini_profiler/storage/memory_store.rb, line 29 def load(id) @timer_struct_lock.synchronize { @timer_struct_cache[id] } end
# File Ruby/lib/mini_profiler/storage/memory_store.rb, line 23 def save(page_struct) @timer_struct_lock.synchronize { @timer_struct_cache[page_struct['Id']] = page_struct } end
Generated with the Darkfish Rdoc Generator 2.