-
-
Save jjasghar/423d040444a4f4cbea1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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