File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ toc_landing_pages = [
1313 " /quick-start-rails" ,
1414 " /quick-start-sinatra" ,
1515 " /interact-data/specify-query" ,
16- " /issues-and-help"
16+ " /issues-and-help" ,
1717]
1818
1919[constants ]
@@ -31,5 +31,6 @@ server-manual = "Server manual"
3131api = " https://www.mongodb.com/docs/mongoid/current/api"
3232ruby-api = " https://www.mongodb.com/docs/ruby-driver/current/api"
3333active-record-docs = " https://guides.rubyonrails.org"
34+ ruby-lang-api = " https://docs.ruby-lang.org/en/3.4"
3435shared-library = " Automatic Encryption Shared Library"
3536mdb-server = " MongoDB Server"
Original file line number Diff line number Diff line change @@ -162,6 +162,25 @@ instance:
162162 :emphasize-lines: 6, 10-15
163163 :dedent:
164164
165+ .. _mongoid-callbacks-thread-local-vars:
166+
167+ Thread-Local Variables
168+ ~~~~~~~~~~~~~~~~~~~~~~
169+
170+ If you have embedded child documents in an association that has
171+ ``cascade_callbacks: true`` configured, then the embedded child
172+ callbacks are executed within a {+language+} `Fiber
173+ <{+ruby-lang-api+}/Fiber.html>`__. This means that if you are using the
174+ ``Thread#[]`` and ``Thread#[]=`` methods to get and set fiber-local
175+ variables, those callbacks are not reading or setting the values you expect.
176+
177+ We recommend that you use the ``Thread#thread_variable_get`` and
178+ ``Thread#thread_variable_set`` methods to get and set true
179+ thread-local variables. For convenience, {+odm+} v9.0.3 introduces
180+ the `Mongoid::Threaded.get <{+api+}/Mongoid/Threaded.html#get-instance_method>`__
181+ and `Mongoid::Threaded.set <{+api+}/Mongoid/Threaded.html#set-instance_method>`__
182+ methods to implement this functionality.
183+
165184Additional Information
166185----------------------
167186
Original file line number Diff line number Diff line change @@ -178,6 +178,17 @@ Removal of Deprecated Functionality
178178- The deprecated class ``{+odm+}::Errors::InvalidStorageParent`` has
179179 been removed.
180180
181+ Get and Set Thread-Local Variables
182+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183+
184+ .. versionadded:: 9.0.3
185+
186+ You can use the `Mongoid::Threaded.get <{+api+}/Mongoid/Threaded.html#get-instance_method>`__
187+ and `Mongoid::Threaded.set <{+api+}/Mongoid/Threaded.html#set-instance_method>`__
188+ methods to query and modify thread-local variables. To learn when to use
189+ these methods, see the :ref:`mongoid-callbacks-thread-local-vars`
190+ section of the Callbacks guide.
191+
181192Index Verification Configuration
182193~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
183194
You can’t perform that action at this time.
0 commit comments