Sha256: 8ad842d0f241cd9bce0b4d086889dca880a9dd965c638b9ca4df6ab411d3eb4a

Contents?: true

Size: 728 Bytes

Versions: 3

Compression:

Stored size: 728 Bytes

Contents

# This class caches store objects for each cache in the system.
class Cachetastic::Connection
  include Singleton
  
  attr_accessor :connections
  
  def initialize
    self.connections = {}
  end
  
  # Takes the name of the cache and returns back the store object associated with the cache.
  # If the store object doesn't exist of the the store is no longer valid a new one is
  # created and returned.
  def get(name)
    name = name.to_sym
    conn = self.connections[name]
    return conn if conn && conn.valid?
    store = Cachetastic::Stores::Base.get_options(name)["store"].camelcase
    conn = "Cachetastic::Stores::#{store}".constantize.new(name)
    self.connections[name.to_sym] = conn
    return conn
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cachetastic-1.0.7 lib/cachetastic_connection.rb
cachetastic-1.0.8 lib/cachetastic_connection.rb
cachetastic-1.1.3 lib/cachetastic_connection.rb