Skip to content

Instantly share code, notes, and snippets.

@jjasghar
Forked from lwoodson/rdb_bloater.rb
Last active December 23, 2015 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjasghar/423d040444a4f4cbea1d to your computer and use it in GitHub Desktop.
Save jjasghar/423d040444a4f4cbea1d to your computer and use it in GitHub Desktop.
require 'redis'
class Bloater
def clear!
redis.flushdb
end
def bloat!(size)
i = 0
while(redis_size < size) do
inject("key_#{i += 1}")
end
end
def redis_size
redis.info["used_memory"].to_i
end
private
def inject(key)
redis.set(key, data)
end
def data
`dd if=/dev/urandom bs=1024000 count=1`
end
def redis
@redis ||= Redis.new
end
end
bloater = Bloater.new
bloater.clear!
bloater.bloat! ARGV.shift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment