Class | Cachetastic::Connection |
In: |
lib/cachetastic_connection.rb
|
Parent: | Object |
connections | [RW] |
Takes the name of the cache, that‘s been methodized, and returns back the adapter object associated with the cache. If the adapter object doesn‘t exist or if the adapter is no longer valid (adapter.valid?) a new one is created and returned.
# File lib/cachetastic_connection.rb, line 14 14: def get(name) 15: name = name.to_sym 16: conn = self.connections[name] 17: return conn if conn && conn.valid? 18: adapter = Cachetastic::Adapters::Base.get_options(name)["adapter"].camelcase 19: conn = "Cachetastic::Adapters::#{adapter}".constantize.new(name) 20: self.connections[name.to_sym] = conn 21: return conn 22: end