35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/spiderfw/model/storage/connection_pool.rb', line 35
def get_connection
if Spider.conf.get('storage.shared_connection')
@shared_conn ||= _checkout
return @shared_conn
end
Thread.current[:storage_connections] ||= {}
Thread.current[:storage_connections][storage_type] ||= {}
@connection_mutex.synchronize do
if conn = Thread.current[:storage_connections][storage_type][@connection_params]
@free_connections.delete(conn)
conn
else
conn = _checkout
Thread.current[:storage_connections][storage_type][@connection_params] = conn
@thread_connections[Thread.current.object_id] = [conn, Time.now]
conn
end
end
end
|