Sinatra with a persistent variable

后端 未结 3 1297
甜味超标
甜味超标 2020-12-31 07:28

My sinatra app has to parse a ~60MB XML-file. This file hardly ever changes: on a nightly cron job, It is overwritten with another one.

Are there tricks or ways to

3条回答
  •  隐瞒了意图╮
    2020-12-31 08:09

    You could try:

    configure do
      @@nokogiri_object = parse_xml
    end
    

    Then @@nokogiri_object will be available in your request methods. It's a class variable rather than an instance variable, but should do what you want.

提交回复
热议问题