# File lib/familia/tools.rb, line 34
    def rename(filter, source_uri, target_uri=nil, &each_key)
      target_uri ||= source_uri
      move_keys filter, source_uri, target_uri if source_uri != target_uri
      source_keys = Familia.redis(source_uri).keys(filter)
      puts "Renaming #{source_keys.size} keys from #{source_uri} (filter: #{filter})"
      source_keys.each_with_index do |key,idx|
        Familia.trace :RENAME1, Familia.redis(source_uri), "#{key}", ''
        type = Familia.redis(source_uri).type key
        ttl = Familia.redis(source_uri).ttl key
        newkey = each_key.call(idx, type, key, ttl) unless each_key.nil?
        Familia.trace :RENAME2, Familia.redis(source_uri), "#{key} -> #{newkey}", caller[0]
        ret = Familia.redis(source_uri).renamenx key, newkey
      end
    end