Skip to content

Commit

Permalink
Merge pull request #21388 from agrare/add_memcached_ping
Browse files Browse the repository at this point in the history
Add a memcached_ping tool
  • Loading branch information
Fryguy authored Aug 20, 2021
2 parents d6294e5 + 6dcd34b commit ad708e9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tools/memcached_ping.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby

require 'dalli'
require 'benchmark'

server_host = ENV.fetch("MEMCACHED_SERVICE_HOST", "localhost")
server_port = ENV.fetch("MEMCACHED_SERVICE_PORT", "11211")
server_address = "#{server_host}:#{server_port}"

begin
client = Dalli::Client.new(server_address)
avg = 10.times.map { Benchmark.realtime { client.get("test") } }.inject(:+) / 10.0

puts "Average: #{avg.round(8)} seconds"
rescue => err
puts "Failed: #{err}"
end

0 comments on commit ad708e9

Please sign in to comment.