getting and setting values in the Thread.current hash appears in the RoR code a bunch of times, including in active_record and active_support.
I keep getting conflicting information, however, on whether information stored in Thread.current is dependable.
In essence, this is my question:
Is the Thread.current hash guaranteed to be available and private throughout one and only one request-response cycle?
In other words, if I do something like:
Thread.current[:my_own_very_special_key] = 1
at the beginning of a response, can I count on all parts of my application, including models(*), to reliably access that value?
Provided I also do:
Thread.current[:my_own_very_special_key] = nil
just before the end of the response (say, in a controller’s after_filter), am I guaranteed that the information is not leaked to other processes/threads/requests/browsers/users?
(OK, I have just given out my ignorance of webserver and webapp framework innards. Oh well…)
(*) I know that accessing Thread.current from my models is frowned upon, but I would very much like to know if the practice is safe, albeit ugly.