使用 Memcached Sinatra 风格的 NoMethodError
我刚刚在 Mac 上安装了 Memcached 并更新了我的 Sinatra 应用程序配置,如 Heroku 的 文档中所述,但是当我尝试使用他们指定的基于哈希的语法时,我收到了 NoMethodError
:
>> CACHE['color'] = 'blue'
>> CACHE['color']
使用显式 get
和 set
下面的方法似乎效果很好。
>> CACHE.set('color', 'blue')
>> CACHE.get('color')
如果有必要我可以使用后一种语法,但前者看起来更优雅。我还没有在 Heroku 的环境中测试过这个,因为我希望我使用的任何实现也能在我的本地环境中工作。谢谢!
I've just installed Memcached on my Mac and updated my Sinatra app configuration as described in Heroku's documentation, but I'm getting a NoMethodError
when trying to use the hash-based syntax they specify:
>> CACHE['color'] = 'blue'
>> CACHE['color']
Using explicit get
and set
methods as below seems to work fine.
>> CACHE.set('color', 'blue')
>> CACHE.get('color')
If necessary I can use the latter syntax, but the former seems more elegant. I haven't tested this on Heroku's environment since I'd like whatever implementation I use to work on my local environment as well. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以这样做:
You could do this: