Class: FastCache::Connection

Inherits:
Object
  • Object
show all
Includes:
Memcache::Protocol
Defined in:
lib/fastcache/interface/connection.rb

Direct Known Subclasses

Dictionary, Evaluator

Instance Attribute Summary collapse

Instance Method Summary collapse

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) ⇒ Connection

Returns a new instance of Connection.



7
8
9
10
11
12
# File 'lib/fastcache/interface/connection.rb', line 7

def initialize(nodes, opts)
  @nodes = nodes.map {|(host, port)| FastCache::Memcache::Node.new(host, port)}
  @bucket_class = FastCache::ModulusBucket
  @hash_class = FastCache::CRC32
  @marshal_module = Marshal # Ruby's built in marshal
end

Instance Attribute Details

#bucket_classObject

Returns the value of attribute bucket_class.



4
5
6
# File 'lib/fastcache/interface/connection.rb', line 4

def bucket_class
  @bucket_class
end

#hash_classObject

Returns the value of attribute hash_class.



4
5
6
# File 'lib/fastcache/interface/connection.rb', line 4

def hash_class
  @hash_class
end

#marshal_moduleObject

Returns the value of attribute marshal_module.



4
5
6
# File 'lib/fastcache/interface/connection.rb', line 4

def marshal_module
  @marshal_module
end

#nodesObject (readonly)

Returns the value of attribute nodes.



5
6
7
# File 'lib/fastcache/interface/connection.rb', line 5

def nodes
  @nodes
end

Instance Method Details

#closeObject



14
15
16
# File 'lib/fastcache/interface/connection.rb', line 14

def close
  @nodes.each do |node| node.close end
end