Sha256: 453db851b2341a9f9d17d92fa715eb119a511d719c7dcb311d003967206798d8

Contents?: true

Size: 676 Bytes

Versions: 7

Compression:

Stored size: 676 Bytes

Contents

module Kestrel
  class Client
    class Blocking < Proxy
      DEFAULT_EXPIRY = 0
      WAIT_TIME_BEFORE_RETRY = 0.25

      def get(*args)
        while !(response = client.get(*args))
          sleep WAIT_TIME_BEFORE_RETRY
        end
        response
      end

      def get_without_blocking(*args)
        client.get(*args)
      end

      def set(key, value, expiry = DEFAULT_EXPIRY, raw = false)
        @retried = false
        begin
          client.set(key, value, expiry, raw)
        rescue Memcached::Error => e
          raise if @retried
          sleep(WAIT_TIME_BEFORE_RETRY)
          @retried = true
          retry
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kestrel-client-0.3.1 lib/kestrel/client/blocking.rb
kestrel-client-0.3.0 lib/kestrel/client/blocking.rb
kestrel-client-0.2.4 lib/kestrel/client/blocking.rb
kestrel-client-0.2.3 lib/kestrel/client/blocking.rb
kestrel-client-0.2.2 lib/kestrel/client/blocking.rb
kestrel-client-0.2.1 lib/kestrel/client/blocking.rb
kestrel-client-0.2.0 lib/kestrel/client/blocking.rb