def keys(options = { })
      if options.include? :range
        warn "range supersedes prefix" if options[:prefix]
        range = options[:range]
        unless range.respond_to?(:first) and range.respond_to?(:last)
          fail ArgumentError, "Range or two element Array expected"
        end
        start          = cast_key_in(range.first)
        include_start  = !options.fetch(:exclude_start, false)
        finish         = cast_key_in(range.last)
        include_finish = !( range.respond_to?(:exclude_end?) ?
                            range.exclude_end?               :
                            options.fetch(:exclude_end, false) )
      else
        fail ArgumentError, "prefix not supported" if options[:prefix]
        start          = cast_key_in(:min)
        include_start  = true
        finish         = cast_key_in(:max)
        include_finish = true
      end
      limit = options.fetch(:limit, -1)
      Utilities.temp_int do |count|
        begin
          list  = lib.range(@db, start, finish, limit, count)
          array = list.get_array_of_uint64(0, count.get_int(0))
          array.shift if array.first == start  and not include_start
          array.pop   if array.last  == finish and not include_finish
          array  # cast not needed:  already Integer
        ensure
          Utilities.free(list) if list
        end
      end
    end
def keys(options = { })
      if options.include? :range
        warn "range supersedes prefix" if options[:prefix]
        range = options[:range]
        unless range.respond_to?(:first) and range.respond_to?(:last)
          fail ArgumentError, "Range or two element Array expected"
        end
        start          = cast_key_in(range.first)
        include_start  = !options.fetch(:exclude_start, false)
        finish         = cast_key_in(range.last)
        include_finish = !( range.respond_to?(:exclude_end?) ?
                            range.exclude_end?               :
                            options.fetch(:exclude_end, false) )
      else
        fail ArgumentError, "prefix not supported" if options[:prefix]
        start          = cast_key_in(:min)
        include_start  = true
        finish         = cast_key_in(:max)
        include_finish = true
      end
      limit = options.fetch(:limit, -1)
      Utilities.temp_int do |count|
        begin
          list  = lib.range(@db, start, finish, limit, count)
          array = list.get_array_of_uint64(0, count.get_int(0))
          array.shift if array.first == start  and not include_start
          array.pop   if array.last  == finish and not include_finish
          array  # cast not needed:  already Integer
        ensure
          Utilities.free(list) if list
        end
      end
    end
Getting and Setting Keys