lib/redis_cleaner.rb
def delete_keys_in_temp_file(params = {})
    batch_size = params.fetch(:batch_size, 20)
    verbose = params.fetch(:verbose, true)

    total_keys_count = 0
    deleted_keys_count = 0

    File.foreach(temp_file_path).each_slice(batch_size) do |keys_group|
      total_keys_count = total_keys_count + keys_group.size
      if removed_keys_count = remove_from_redis(strip_keys_group(keys_group))
        puts "Successfully deleted key group of size #{keys_group.size}" if verbose
        deleted_keys_count = deleted_keys_count + removed_keys_count
      else
        puts "Failed to delete: #{keys_group.inspect}" if verbose
      end
    end

    {total_keys_count: total_keys_count, deleted_keys_count: deleted_keys_count}
  end
# takes params inside a hash
#   :batch_size defaults to 20
#   :verbose defaults to true
takes params inside a hash
:batch_size defaults to 20
:verbose defaults to true
takes params inside a hash : batch_size defaults to 20 : verbose defaults to true
def delete_keys_in_temp_file(params = {})
    batch_size = params.fetch(:batch_size, 20)
    verbose = params.fetch(:verbose, true)
    total_keys_count = 0
    deleted_keys_count = 0
    File.foreach(temp_file_path).each_slice(batch_size) do |keys_group|
      total_keys_count = total_keys_count + keys_group.size
      if removed_keys_count = remove_from_redis(strip_keys_group(keys_group))
        puts "Successfully deleted key group of size #{keys_group.size}" if verbose
        deleted_keys_count = deleted_keys_count + removed_keys_count
      else
        puts "Failed to delete: #{keys_group.inspect}" if verbose
      end
    end
    {total_keys_count: total_keys_count, deleted_keys_count: deleted_keys_count}
  end
def delete_keys_in_temp_file ( params = { } ) batch_size = params . fetch ( :batch_size , 20 ) verbose = params . fetch ( :verbose , true ) total_keys_count = 0 deleted_keys_count = 0 File . foreach ( temp_file_path ) . each_slice ( batch_size ) do | keys_group | total_keys_count = total_keys_count + keys_group . size if removed_keys_count = remove_from_redis ( strip_keys_group ( keys_group ) ) puts "Successfully deleted key group of size #{keys_group.size}" if verbose deleted_keys_count = deleted_keys_count + removed_keys_count else puts "Failed to delete: #{keys_group.inspect}" if verbose end end { total_keys_count : total_keys_count , deleted_keys_count : deleted_keys_count } end
takes params inside a hash
:batch_size defaults to 20
:verbose defaults to true
takes params inside a hash : batch_size defaults to 20 : verbose defaults to true
params