Ruby Singleton 和 Shotgun
我从 Ruby 开始,我们的团队领导让我们学习 Sinatra,重新加载应用程序更改是由 Shotgun 完成的,我现在的问题是我有一个 Singleton 实体 我希望在请求之间保留状态,但显然 Shotgun 会在每个请求之间重新启动。
对此的任何帮助或解释将不胜感激,
提前致谢。
Im starting with Ruby and our team leader sends us to learn Sinatra, reloading the application changes is been done by Shotgun, my problem now is that i have a Singleton entity
which i would love to keep states between request, but aparently Shotgun restarts is every request.
Any Help or Explanation on this would be apreciated,
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不应期望在请求之间(无论是否使用 Shotgun)保存应用程序状态的任何内容,除非将其保存在会话数据中。
You shouldn't expect anything about your application's state to be saved between requests at all (Shotgun or not) unless it is being saved in session data.
为了让会话在 Shotgun 中持续存在,您需要设置密钥...否则它会在每次页面加载时重置。
For sessions to persist with Shotgun you need to set the key... Otherwise it is reset with every page load.