AdoccaMemcache 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/Rakefile +1 -1
  2. data/lib/am_memcache.rb +15 -11
  3. metadata +1 -1
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
  require './lib/adocca_memcache.rb'
6
6
 
7
- Hoe.new('AdoccaMemcache', '0.1.6') do |p|
7
+ Hoe.new('AdoccaMemcache', '0.1.7') do |p|
8
8
  p.rubyforge_name = 'adocca-plugins'
9
9
  p.author = 'adocca Entertainment AB'
10
10
  p.summary = 'A client library to simplify using memcached with Ruby on Rails projects.'
data/lib/am_memcache.rb CHANGED
@@ -43,9 +43,13 @@ module Adocca
43
43
 
44
44
  # Default memcached server weight.
45
45
  DEFAULT_WEIGHT = 1
46
-
47
- # Default interval between checking server liveliness
48
- VALIDATION_INTERVAL = 30
46
+
47
+ #
48
+ # The maximum amount of time we are willing to spend
49
+ # talking to servers before accepting that something
50
+ # horrible has happened.
51
+ #
52
+ LIVELINESS_TIMEOUT = 5
49
53
 
50
54
  # The amount of time to wait for a response from a memcached server. If a
51
55
  # response is not completed within this time, the connection to the server
@@ -272,8 +276,10 @@ module Adocca
272
276
  end
273
277
 
274
278
  begin
275
- sock.write "flush_all\r\n"
276
- sock.gets
279
+ timeout(LIVELINESS_TIMEOUT) do
280
+ sock.write "flush_all\r\n"
281
+ sock.gets
282
+ end
277
283
  rescue Exception => err
278
284
  server.mark_dead(err.message)
279
285
  raise MemCacheError, err.message
@@ -359,10 +365,6 @@ module Adocca
359
365
  # connection with a server that is marked dead.
360
366
  RETRY_DELAY = 10
361
367
 
362
- # Default timeout for getting all the necessary info from the server when
363
- # checking liveliness
364
- LIVELINESS_TIMEOUT = 5
365
-
366
368
  # The host the memcached server is running on.
367
369
  attr_reader :host
368
370
 
@@ -509,8 +511,10 @@ module Adocca
509
511
 
510
512
  response = nil
511
513
  begin
512
- sock.write "#{command}\r\n"
513
- [sock.gets, sock, server]
514
+ timeout(LIVELINESS_TIMEOUT) do
515
+ sock.write "#{command}\r\n"
516
+ [sock.gets, sock, server]
517
+ end
514
518
  rescue Exception => err
515
519
  server.mark_dead(err.message)
516
520
  raise MemCacheError, err.message
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: AdoccaMemcache
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.6
6
+ version: 0.1.7
7
7
  date: 2007-02-12 00:00:00 +01:00
8
8
  summary: A client library to simplify using memcached with Ruby on Rails projects.
9
9
  require_paths: