Class: RIO::FTP::ConnCache

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/rio/ftp/conncache.rb

Instance Method Summary collapse

Constructor Details

#initializeConnCache

Returns a new instance of ConnCache.



61
62
63
64
# File 'lib/rio/ftp/conncache.rb', line 61

def initialize()
  @conns = {}
  @count = {}
end

Instance Method Details

#close(uri) ⇒ Object



79
80
81
82
# File 'lib/rio/ftp/conncache.rb', line 79

def close(uri)
  key = urikey(uri)
  @count[key] -= 1
end

#connect(uri) ⇒ Object



70
71
72
73
74
75
76
77
78
# File 'lib/rio/ftp/conncache.rb', line 70

def connect(uri)
  key = urikey(uri)
  unless @conns.has_key?(key)
    @conns[key] = Connection.new(uri)
    @count[key] = 0
  end
  @count[key] += 1
  @conns[key]
end

#urikey(uri) ⇒ Object



65
66
67
68
69
# File 'lib/rio/ftp/conncache.rb', line 65

def urikey(uri)
  key_uri = uri.clone
  key_uri.path = ''
  key_uri.to_s
end