Class: FastCache::Connection
- Inherits:
-
Object
- Object
- FastCache::Connection
- Includes:
- Memcache::Protocol
- Defined in:
- lib/fastcache/interface/connection.rb
Direct Known Subclasses
Constant Summary collapse
- CONNECTION_OPTIONS =
{ :router => FastCache::BasicRouter}
Instance Attribute Summary collapse
-
#router ⇒ Object
Returns the value of attribute router.
Instance Method Summary collapse
- #close_all_connections ⇒ Object
-
#initialize(nodes, opts = nil) ⇒ Connection
constructor
A new instance of Connection.
Methods included from Memcache::Protocol
#add, #cas, #decr, #delete, #flush_all_caches, #flush_cache, #get, #incr, #replace, #reset_connections, #set, #stats
Constructor Details
#initialize(nodes, opts = nil) ⇒ Connection
Returns a new instance of Connection.
9 10 11 12 13 |
# File 'lib/fastcache/interface/connection.rb', line 9 def initialize(nodes, opts = nil) opts = CONNECTION_OPTIONS.merge(opts || {}) @nodes = nodes.map {|(host, port)| FastCache::Memcache::Node.new(host, port)} @router = opts[:router].new(@nodes) end |
Instance Attribute Details
#router ⇒ Object
Returns the value of attribute router.
4 5 6 |
# File 'lib/fastcache/interface/connection.rb', line 4 def router @router end |
Instance Method Details
#close_all_connections ⇒ Object
15 16 17 |
# File 'lib/fastcache/interface/connection.rb', line 15 def close_all_connections @nodes.each do |node| node.close end end |