Class: MemcacheCheck::Checker
- Inherits:
-
Object
- Object
- MemcacheCheck::Checker
- Defined in:
- lib/memcache_check.rb
Instance Attribute Summary collapse
-
#fails ⇒ Object
readonly
Returns the value of attribute fails.
-
#passes ⇒ Object
readonly
Returns the value of attribute passes.
Instance Method Summary collapse
- #create_key_value_pair ⇒ Object
-
#initialize(server = 'localhost', port = '11211') ⇒ Checker
constructor
A new instance of Checker.
- #is_valid?(key, value) ⇒ Boolean
- #start(num_times = 50) ⇒ Object
- #test_server ⇒ Object
Constructor Details
Instance Attribute Details
#fails ⇒ Object (readonly)
Returns the value of attribute fails.
8 9 10 |
# File 'lib/memcache_check.rb', line 8 def fails @fails end |
#passes ⇒ Object (readonly)
Returns the value of attribute passes.
8 9 10 |
# File 'lib/memcache_check.rb', line 8 def passes @passes end |
Instance Method Details
#create_key_value_pair ⇒ Object
39 40 41 |
# File 'lib/memcache_check.rb', line 39 def create_key_value_pair [Utils.generate_key, Utils.generate_test_data] end |
#is_valid?(key, value) ⇒ Boolean
43 44 45 |
# File 'lib/memcache_check.rb', line 43 def is_valid?(key, value) value == @server.get(key) end |
#start(num_times = 50) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/memcache_check.rb', line 16 def start(num_times = 50) time = Benchmark.measure do num_times.times do test_server end end [@passes, @fails, time.real] end |
#test_server ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/memcache_check.rb', line 25 def test_server key, value = create_key_value_pair begin @server.set(key, value) if is_valid?(key, value) @passes += 1 else @fails += 1 end rescue @fails += 1 end end |