cas (MemCache)

    # File lib/active_support/vendor/memcache-client-1.7.4/memcache.rb, line 355
      def cas(key, expiry=0, raw=false)
        raise MemCacheError, "Update of readonly cache" if @readonly
        raise MemCacheError, "A block is required" unless block_given?

        (value, token) = gets(key, raw)
        return nil unless value
        updated = yield value

        with_server(key) do |server, cache_key|

          value = Marshal.dump updated unless raw
          logger.debug { "cas #{key} to #{server.inspect}: #{value.to_s.size}" } if logger
          command = "cas #{cache_key} 0 #{expiry} #{value.to_s.size} #{token}#{noreply}\r\n#{value}\r\n"

          with_socket_management(server) do |socket|
            socket.write command
            break nil if @no_reply
            result = socket.gets
            raise_on_error_response! result

            if result.nil?
              server.close
              raise MemCacheError, "lost connection to #{server.host}:#{server.port}"
            end

            result
          end
        end
      end