Class: Xunch::ShardInfo
- Inherits:
-
Object
- Object
- Xunch::ShardInfo
- Defined in:
- lib/xunch/shard/shard_info.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :host => "127.0.0.1", :port => 6379, :name => nil, :password => nil, :timeout => nil, :db => 0, :weight => 40, :size => 1 }
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#host ⇒ Object
Returns the value of attribute host.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#weight ⇒ Object
Returns the value of attribute weight.
Instance Method Summary collapse
- #create_resource ⇒ Object
-
#initialize(options) ⇒ ShardInfo
constructor
A new instance of ShardInfo.
- #to_s ⇒ Object
Constructor Details
#initialize(options) ⇒ ShardInfo
Returns a new instance of ShardInfo.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/xunch/shard/shard_info.rb', line 16 def initialize() raise "initialize ShardInfo error, options can not be nil." if == nil @options = DEFAULT_OPTIONS.merge() @host = @options[:host] @port = @options[:port] @name = @options[:name] @password = @options[:password] @timeout = @options[:timeout] @db = @options[:db] @weight = @options[:weight] end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def database @database end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def host @host end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def port @port end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def timeout @timeout end |
#weight ⇒ Object
Returns the value of attribute weight.
3 4 5 |
# File 'lib/xunch/shard/shard_info.rb', line 3 def weight @weight end |
Instance Method Details
#create_resource ⇒ Object
29 30 31 |
# File 'lib/xunch/shard/shard_info.rb', line 29 def create_resource RedisClient.new(@options) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/xunch/shard/shard_info.rb', line 33 def to_s "#{@host}:#{@port}::#{@db}*#{@weight}"; end |