Class: CassandraModel::ConnectionCache

Inherits:
Object
  • Object
show all
Defined in:
lib/cassandra_model/connection_cache.rb

Constant Summary collapse

MUTEX =
Mutex.new
@@cache =
build_cache

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



12
13
14
# File 'lib/cassandra_model/connection_cache.rb', line 12

def [](key)
  @@cache[key]
end

.build_cacheObject



6
7
8
9
10
# File 'lib/cassandra_model/connection_cache.rb', line 6

def build_cache
  Hash.new do |hash, key|
    MUTEX.synchronize { hash[key] = RawConnection.new(key) }
  end
end

.clearObject



16
17
18
19
# File 'lib/cassandra_model/connection_cache.rb', line 16

def clear
  @@cache.values.map(&:shutdown)
  @@cache.clear
end