aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2015-07-08 18:30:22 +0200
committerDavid Heinemeier Hansson <david@loudthinking.com>2015-07-08 22:49:34 +0200
commit4c20f1b810595a8eb8b321a24768c7b80be9b98d (patch)
tree9668370ad91eb45ec0d57a9cca6959b348db54bc
parent6c0135e41ba13d3537c4cde3900c4d02dc9a88cf (diff)
downloadrails-4c20f1b810595a8eb8b321a24768c7b80be9b98d.tar.gz
rails-4c20f1b810595a8eb8b321a24768c7b80be9b98d.tar.bz2
rails-4c20f1b810595a8eb8b321a24768c7b80be9b98d.zip
Mention the concern about long-lived and stale data
-rw-r--r--lib/action_cable/channel/base.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/action_cable/channel/base.rb b/lib/action_cable/channel/base.rb
index 2c89ccace4..9c23ba382b 100644
--- a/lib/action_cable/channel/base.rb
+++ b/lib/action_cable/channel/base.rb
@@ -7,7 +7,10 @@ module ActionCable
# Channel instances are long-lived. A channel object will be instantiated when the cable consumer becomes a subscriber, and then
# lives until the consumer disconnects. This may be seconds, minutes, hours, or even days. That means you have to take special care
# not to do anything silly in a channel that would balloon its memory footprint or whatever. The references are forever, so they won't be released
- # as is normally the case with a controller instance that gets thrown away after every request.
+ # as is normally the case with a controller instance that gets thrown away after every request.
+ #
+ # Long-lived channels (and connections) also mean you're responsible for ensuring that the data is fresh. If you hold a reference to a user
+ # record, but the name is changed while that reference is held, you may be sending stale data if you don't take precautions to avoid it.
#
# The upside of long-lived channel instances is that you can use instance variables to keep reference to objects that future subscriber requests
# can interact with. Here's a quick example: