[英]How to Save A Tiny Bit Of Data In Rails On Heroku
I have a super simple Ruby on Rails app that doesn't have any ActiveRecord code. 我有一个超级简单的Ruby on Rails应用,没有任何ActiveRecord代码。 The app saves literally one line of text via a "record" URL. 该应用程序实际上通过“记录” URL保存一行文本。 I want to be able to then hit a URL that feeds back whatever line of text was recorded. 然后,我希望能够找到一个URL,该URL反馈记录的任何文本行。 Like this: 像这样:
Person 1: POST to www.myUrl.heroku.com/recorder, DATA = "A really interesting string" 第1个人:POST到www.myUrl.heroku.com/recorder,DATA =“一个非常有趣的字符串”
Person 2: GET to www.myUrl.heroku.com/recorder, I want my response to contain "A really interesting string" 人2:获取www.myUrl.heroku.com/recorder,我希望我的回复包含“一个非常有趣的字符串”
This sounds SUPER SIMPLE which is why I am mega-frustrated that I can't do it. 这听起来超级简单,这就是为什么我为无法做到而感到沮丧。 Heroku has an ephemeral file system - I read all about that. Heroku有一个临时文件系统-我读了所有有关它的内容。 And Heroku logs can't be accessed from within the app (as far as I can tell) - I can use command line tools but that doesn't help. Heroku日志无法从应用程序内访问(据我所知)-我可以使用命令行工具,但这无济于事。 But I only need the data there for 10 minutes! 但是我只需要那里的数据10分钟!
Here are the things we tried so far: 这是到目前为止我们尝试过的事情:
I really don't want to sign up for AWS since this is a service for someone else, and it seems ridiculous to sign up for 1 tb of data transfer for literally 1 line of text (it overwrites anytime someone "records"). 我真的不想注册AWS,因为这是为其他人提供的服务,并且为1行文本注册1 TB的数据传输似乎很可笑(在有人“记录”时,它会被覆盖)。 I also would prefer not to create a whole ActiveRecord deal given, again, literally 1 line of text. 我也不想再给定字面上的1行文本来创建整个ActiveRecord处理。
Any ideas here? 这里有什么想法吗? Is there some micro cache or whatever I can use? 是否有一些微缓存或我可以使用的任何缓存? I only need the data to persist for about 10 minutes. 我只需要将数据保留大约10分钟即可。
Thanks! 谢谢!
Damien 达米安
PS Using Ruby 2.0, rails 3.something. PS使用Ruby 2.0,rails 3.something。
您可以利用Rails应用程序缓存-rails.cache.write('key','value')和rails.cache.read('key')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.