Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do ruby class variables get cleared between Rails requests?

For a caching mechanism for my Rails app I am setting a class variable in an instance method which is then later accessed in a class method. This works, but I'm a bit paranoid that there could be a memory leak. Therefore does anyone know if Rails @@class variables are cleared between requests? I have tried this out (on my local development environment), but you never know.

like image 251
matsko Avatar asked Feb 15 '26 16:02

matsko


1 Answers

They dont get cleared if you have config.cache_classes = true, which is generally the case in production.

like image 149
zsquare Avatar answered Feb 18 '26 06:02

zsquare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!