Sha256: 84a34ae95db7e625849c35fb9f867c086e36412fa476e00c0c3b94b6bda20318
Contents?: true
Size: 858 Bytes
Versions: 5
Compression:
Stored size: 858 Bytes
Contents
# -*- encoding: binary -*- module Regurgitator::ListKeys 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
5 entries across 5 versions & 1 rubygems