2008-07-31 17:39:48 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
# This is a really simple session storage daemon, basically just a hash,
|
2004-11-23 20:04:44 -05:00
|
|
|
# which is enabled for DRb access.
|
2008-07-31 17:39:48 -04:00
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
require 'drb'
|
|
|
|
|
2005-01-02 11:00:50 -05:00
|
|
|
session_hash = Hash.new
|
|
|
|
session_hash.instance_eval { @mutex = Mutex.new }
|
|
|
|
|
|
|
|
class <<session_hash
|
|
|
|
def []=(key, value)
|
|
|
|
@mutex.synchronize do
|
|
|
|
super(key, value)
|
|
|
|
end
|
|
|
|
end
|
2008-07-31 17:39:48 -04:00
|
|
|
|
2005-01-02 11:00:50 -05:00
|
|
|
def [](key)
|
|
|
|
@mutex.synchronize do
|
|
|
|
super(key)
|
|
|
|
end
|
|
|
|
end
|
2008-07-31 17:39:48 -04:00
|
|
|
|
2005-01-02 11:00:50 -05:00
|
|
|
def delete(key)
|
|
|
|
@mutex.synchronize do
|
|
|
|
super(key)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
DRb.start_service('druby://127.0.0.1:9192', session_hash)
|
2008-07-31 17:39:48 -04:00
|
|
|
DRb.thread.join
|