memcachedb-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/memcachedb.rb +45 -44
  3. metadata +2 -2
@@ -2,4 +2,4 @@
2
2
  :build:
3
3
  :major: 0
4
4
  :minor: 0
5
- :patch: 1
5
+ :patch: 2
@@ -630,6 +630,51 @@ class MemCacheDb
630
630
  def []=(key, value)
631
631
  set key, value
632
632
  end
633
+
634
+
635
+ ##
636
+ # Gets or creates a socket connected to the given server, and yields it
637
+ # to the block, wrapped in a mutex synchronization if @multithread is true.
638
+ #
639
+ # If a socket error (SocketError, SystemCallError, IOError) or protocol error
640
+ # (MemCacheDbError) is raised by the block, closes the socket, attempts to
641
+ # connect again, and retries the block (once). If an error is again raised,
642
+ # reraises it as MemCacheDbError.
643
+ #
644
+ # If unable to connect to the server (or if in the reconnect wait period),
645
+ # raises MemCacheDbError. Note that the socket connect code marks a server
646
+ # dead for a timeout period, so retrying does not apply to connection attempt
647
+ # failures (but does still apply to unexpectedly lost connections etc.).
648
+
649
+ def with_socket_management(server, &block)
650
+ check_multithread_status!
651
+ @mutex.lock if @multithread
652
+ retried = false
653
+
654
+ begin
655
+ socket = server.socket
656
+ # Raise an IndexError to show this server is out of whack. If were inside
657
+ # a with_server block, we'll catch it and attempt to restart the operation.
658
+
659
+ raise IndexError, "No connection to server (#{server.status})" if socket.nil?
660
+
661
+ block.call(socket)
662
+
663
+ rescue SocketError, Errno::EAGAIN, Timeout::Error => err
664
+
665
+ logger.warn { "Socket failure: #{err.message}" } if logger
666
+ server.mark_dead(err)
667
+ handle_error(server, err)
668
+
669
+ rescue MemCacheDbError, SystemCallError, IOError => err
670
+ logger.warn { "Generic failure: #{err.class.name}: #{err.message}" } if logger
671
+ handle_error(server, err) if retried || socket.nil?
672
+ retried = true
673
+ retry
674
+ end
675
+ ensure
676
+ @mutex.unlock if @multithread
677
+ end
633
678
 
634
679
  protected unless $TESTING
635
680
 
@@ -804,50 +849,6 @@ class MemCacheDb
804
849
  end
805
850
  end
806
851
 
807
- ##
808
- # Gets or creates a socket connected to the given server, and yields it
809
- # to the block, wrapped in a mutex synchronization if @multithread is true.
810
- #
811
- # If a socket error (SocketError, SystemCallError, IOError) or protocol error
812
- # (MemCacheDbError) is raised by the block, closes the socket, attempts to
813
- # connect again, and retries the block (once). If an error is again raised,
814
- # reraises it as MemCacheDbError.
815
- #
816
- # If unable to connect to the server (or if in the reconnect wait period),
817
- # raises MemCacheDbError. Note that the socket connect code marks a server
818
- # dead for a timeout period, so retrying does not apply to connection attempt
819
- # failures (but does still apply to unexpectedly lost connections etc.).
820
-
821
- def with_socket_management(server, &block)
822
- check_multithread_status!
823
- @mutex.lock if @multithread
824
- retried = false
825
-
826
- begin
827
- socket = server.socket
828
- # Raise an IndexError to show this server is out of whack. If were inside
829
- # a with_server block, we'll catch it and attempt to restart the operation.
830
-
831
- raise IndexError, "No connection to server (#{server.status})" if socket.nil?
832
-
833
- block.call(socket)
834
-
835
- rescue SocketError, Errno::EAGAIN, Timeout::Error => err
836
-
837
- logger.warn { "Socket failure: #{err.message}" } if logger
838
- server.mark_dead(err)
839
- handle_error(server, err)
840
-
841
- rescue MemCacheDbError, SystemCallError, IOError => err
842
- logger.warn { "Generic failure: #{err.class.name}: #{err.message}" } if logger
843
- handle_error(server, err) if retried || socket.nil?
844
- retried = true
845
- retry
846
- end
847
- ensure
848
- @mutex.unlock if @multithread
849
- end
850
-
851
852
  def with_server(key, read = false)
852
853
  retried = false
853
854
  begin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memcachedb-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hodel
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2010-02-14 00:00:00 -05:00
15
+ date: 2010-02-20 00:00:00 -05:00
16
16
  default_executable:
17
17
  dependencies: []
18
18