Created
January 28, 2010 19:23
-
-
Save yuiseki/289049 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
require 'tokyotyrant' | |
include TokyoTyrant | |
helpers do | |
def get_recents() | |
rdb = RDBTBL::new | |
rdb.open('localhost', 1978) | |
qry = RDBQRY::new(rdb) | |
qry.setorder('', RDBQRY::QONUMDESC) # 主キーを数値型と想定し降順でソート | |
qry.setlimit(10, 0) # 取得上限件数、オフセット数 | |
qry.searchget | |
end | |
end | |
get '/' do | |
@records = get_recents() | |
result = [] | |
@records.each do |r| | |
r.each_pair{|key, value|result.push "<b>#{key.to_s}</b>: #{value.to_s}<br />"} | |
result.push "<br />" | |
end | |
result.join("") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment