Class: Sunspot::SessionProxy::ThreadLocalSessionProxy
- Inherits:
-
AbstractSessionProxy
- Object
- AbstractSessionProxy
- Sunspot::SessionProxy::ThreadLocalSessionProxy
- Defined in:
- lib/sunspot/session_proxy/thread_local_session_proxy.rb
Overview
This class implements a session proxy that creates a different Session object for each thread. Any multithreaded application should use this proxy.
Constant Summary collapse
- FINALIZER =
Proc.new do |object_id| Thread.current[:"sunspot_session_#{object_id}"] = nil end
- @@next_id =
0
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
The configuration with which the thread-local sessions are initialized.
Instance Method Summary collapse
-
#initialize(config = Sunspot::Configuration.new) ⇒ ThreadLocalSessionProxy
constructor
Optionally pass an existing Sunspot::Configuration object.
-
#session ⇒ Object
:nodoc:.
Methods inherited from AbstractSessionProxy
Constructor Details
#initialize(config = Sunspot::Configuration.new) ⇒ ThreadLocalSessionProxy
Optionally pass an existing Sunspot::Configuration object. If none is passed, a default configuration is used; it can then be modified using the #config attribute.
27 28 29 30 |
# File 'lib/sunspot/session_proxy/thread_local_session_proxy.rb', line 27 def initialize(config = Sunspot::Configuration.new) @config = config ObjectSpace.define_finalizer(self, FINALIZER) end |
Instance Attribute Details
#config ⇒ Object (readonly)
The configuration with which the thread-local sessions are initialized.
17 18 19 |
# File 'lib/sunspot/session_proxy/thread_local_session_proxy.rb', line 17 def config @config end |