使用 Sinatra 应用程序设置 api。
每个请求为 15MB。每次我刷新页面时,它都会增加 15MB 的内存。每次请求后如何清除信息?
require 'rubygems'
require 'sinatra'
require 'active_record'
require 'mysql2'
require 'json'
client = Mysql2::Client.new(adapter: 'mysql2', host: '127.0.0.1', database: 'dev_app', username: 'root', password: 'root')
get '/people' do
q = "select name, age from people;"
people = client.query(q, :as => :json).map{|one| {one['name'] => one['age'].to_i}}
return people.to_json
people = nil
end