Skip to content

Instantly share code, notes, and snippets.

@lwoodson
Last active December 23, 2015 22:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lwoodson/66e0c5202b2b1c357762 to your computer and use it in GitHub Desktop.
Save lwoodson/66e0c5202b2b1c357762 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=1024 count=1`
end
def redis
@redis ||= Redis.new
end
end
bloater = Bloater.new
bloater.clear!
bloater.bloat! ARGV.shift
@lwoodson
Copy link
Author

bloater = Bloater.new
bloater.clear!
bloater.bloat! 2 ** 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment