Sha256: bb764d845025e9c5980736381abab0ba6d14f00c52b30d156193cba1c38ddf69
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'drb' require File.dirname(__FILE__)+'/merb_upload_progress' module Merb class DRbSession include DRbUndumped class << self def setup(opts={}) @opts = opts @sessions = Hash.new @timestamps = Hash.new @mutex = Mutex.new @session_ttl = opts.fetch(:session_ttl, 15*60) # default 15 minutes start_timer self end def create(opts={}) self[opts[:sess_id]] = opts[:data] end def [](key) @mutex.synchronize { @timestamps[key] = Time.now @sessions[key] } end def []=(key, val) @mutex.synchronize { @timestamps[key] = Time.now @sessions[key] = val } end def delete(key) @mutex.synchronize { @sessions.delete(key) } end def reap_old_sessions @timestamps.each do |key,stamp| if stamp + @session_ttl < Time.now delete(key) end end GC.start end def start_timer Thread.new do sleep @session_ttl reap_old_sessions end end def sessions @sessions end def upload_progress ::Merb::UploadProgress.new end end # end singleton class end # end DRbSession end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
merb-0.0.8 | lib/merb/merb_drb_server.rb |