bin/redis-dump in redis-dump-0.1.5 vs bin/redis-dump in redis-dump-0.3.0

- old
+ new

@@ -25,10 +25,13 @@ default :dump trawler :dump global :u, :uri, String, "Redis URI (e.g. redis://hostname[:port])" global :d, :database, Integer, "Redis database (e.g. -d 15)" + global :s, :sleep, Integer, "Sleep for S seconds after dumping (for debugging)" + global :c, :count, Integer, "Chunk size (default: #{Redis::Dump.chunk_size})" + global :O, :without_optimizations, "Disable run time optimizations" global :V, :version, "Display version" do puts "Version: #{Redis::Dump::VERSION.to_s}" exit 0 end global :D, :debug do @@ -41,26 +44,37 @@ before do |obj| obj.global.uri ||= 'redis://%s:%s' % [Redis::Dump.host, Redis::Dump.port] obj.global.uri = 'redis://' << obj.global.uri unless obj.global.uri.match(/^redis:\/\//) obj.global.database &&= obj.global.database.to_i obj.global.database ||= (0..15) + Redis::Dump.with_optimizations = false if obj.global.without_optimizations + Redis::Dump.chunk_size = obj.global.count if obj.global.count Redis::Dump.ld " redis_uri: #{obj.global.uri} (#{obj.global.database})" + Redis::Dump.ld "Process: #{$$}; Memory: #{Redis::Dump.memory_usage}" if Redis::Dump.debug end + after do |obj| + Redis::Dump.ld "Process: #{$$}; Memory: #{Redis::Dump.memory_usage}" if Redis::Dump.debug + sleep obj.global.sleep.to_i if obj.global.sleep + end + usage "redis-dump > dumpfile_full.json" usage "redis-dump -d 15 > dumpfile_db15.json" + usage "redis-dump -d 15 -c 100_000 > dumpfile_db15.json" command :dump do |obj| rd = Redis::Dump.new obj.global.database, obj.global.uri - rd.dump do |record| - puts record + rd.dump do |records| + puts records end end end begin Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run? +rescue RuntimeError => ex + STDERR.puts ex.message rescue Drydock::ArgError, Drydock::OptError => ex STDERR.puts ex.message STDERR.puts ex.usage rescue Drydock::InvalidArgument => ex STDERR.puts ex.message \ No newline at end of file