# Persistent values and class variables

**URL:** <https://www.ruby-forum.com/t/persistent-values-and-class-variables/189923>\
**Category:** Rails\
**Created:** [June 9, 2010, 11:55pm UTC](https://www.ruby-forum.com/t/persistent-values-and-class-variables/189923 "2010-06-09T23:55:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [June 9, 2010, 11:55pm UTC](https://www.ruby-forum.com/t/persistent-values-and-class-variables/189923/1 "2010-06-09T23:55:26Z")

</div>

I need to have a variable that points to a MemCache instance so I looked  
at the Rails caching code to see how they do it. They use a Ruby class  
variable (or a few of them). That surprised me since class variables in  
Ruby as so gnarly.

I thought I would post the question here to see if anyone knew / had an  
opinion. Why would they use a class variable instead of a class  
instance variable? Especially since Rails has some nice support for  
class instance variables.

I’m asking because if there is a reason, I’d like to know so I could  
avoid whatever problems the Rails guys are trying to avoid.

Thank you,  
Perry
