Skip to content

Instantly share code, notes, and snippets.

@bastos
Created February 16, 2009 13:45
Show Gist options
  • Save bastos/65170 to your computer and use it in GitHub Desktop.
Save bastos/65170 to your computer and use it in GitHub Desktop.
Test Memcached
require 'rubygems'
require 'memcache'
memcache_options = {
:namespace => 'agp:test:key',
:multithread => true
}
memcached_servers = [ ENV['MEMCACHED_LOCATION'] || '0.0.0.0:12211']
# Cache configurations. You can force the use of pure ruby memcache lib.
cache_params = *([memcached_servers, memcache_options].flatten)
CACHE = MemCache.new memcache_options
CACHE.servers = memcached_servers
ths = []
100.times do |i|
ths << Thread.new do
CACHE.set "k#{i}","#{Time.now.to_f}-#{i}-value"
CACHE.get "k#{i}"
end
end
ths.each{|t| t.join}
puts ths.size
puts "END"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment