Sha256: fb21f05081d16d122bcaf652297a3e0d804c51f6a4474f6c367c7dd56ac14d35
Contents?: true
Size: 868 Bytes
Versions: 1
Compression:
Stored size: 868 Bytes
Contents
# -*- encoding: binary -*- module Regurgitator::ListKeys # :nodoc: include Regurgitator::Domain LIST_KEYS_MAX = 1000 def list_keys(domain, opts = {}) dmid = get_dmid(domain) or return after, limit, prefix = opts[:after], opts[:limit], opts[:prefix] limit ||= LIST_KEYS_MAX Integer === limit or raise ArgumentError, ":limit not an Integer=#{limit.inspect}" limit = LIST_KEYS_MAX if limit > LIST_KEYS_MAX sql = "SELECT fid,dkey,length,devcount,classid " \ "FROM file WHERE dmid = #{dmid}" sql << " AND dkey LIKE /*! BINARY */ #{@db.literal(prefix+'%')}" if prefix sql << " AND dkey > #{@db.literal(after)}" if after sql << " ORDER BY dkey LIMIT #{limit}" # we don't enforce collation here, give DBAs some freedom... ds = @db[sql] block_given? ? ds.each { |row| yield(row) } : ds.to_a end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
regurgitator-0.7.0 | lib/regurgitator/list_keys.rb |