Class: RIO::FTP::ConnCache
- Includes:
- Singleton
- Defined in:
- lib/rio/ftp/conncache.rb
Instance Method Summary collapse
- #close(uri) ⇒ Object
- #connect(uri) ⇒ Object
-
#initialize ⇒ ConnCache
constructor
A new instance of ConnCache.
- #urikey(uri) ⇒ Object
Constructor Details
#initialize ⇒ ConnCache
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 |