Class Cachetastic::Connection
In: lib/cachetastic_connection.rb
Parent: Object

This class caches adapter objects for each cache in the system.

Methods

get   new  

Included Modules

Singleton

Attributes

connections  [RW] 

Public Class methods

[Source]

   # File lib/cachetastic_connection.rb, line 7
7:   def initialize
8:     self.connections = {}
9:   end

Public Instance methods

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.

[Source]

    # 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

[Validate]