如何在 Rails 3 中将 OmniAuth 与 Memcache 存储结合使用?
我想将 Memcache 用于 OmniAuth 商店,但我找不到任何有关如何执行此操作的示例。文件系统 tmp 不适用于我的主机。如何将下面的omniauth.rb 中的代码转换为使用Memcache。另外,我是否需要任何额外的 gem 才能让 Memcache 正常工作?
谢谢!!
当前的omniauth.rb:
require 'openid/store/filesystem'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, OpenID::Store::Filesystem.new('/tmp'), {:name => "google", :domain => "https://www.google.com/accounts/o8/id" }
end
I would like to use Memcache for OmniAuth's store but I cannot find any examples on how to do this. Filesystem tmp is not working for my host. How can I convert the code in my omniauth.rb below to use Memcache. Also do I need any extra gems to get Memcache to work?
Thanks!!
current omniauth.rb:
require 'openid/store/filesystem'
Rails.application.config.middleware.use OmniAuth::Builder do
provider :open_id, OpenID::Store::Filesystem.new('/tmp'), {:name => "google", :domain => "https://www.google.com/accounts/o8/id" }
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你在 Heroku,因为我也遇到了一些麻烦。我在 Heroku 上使用标准 Memcached 库时遇到了一些问题,尽管我现在不记得它们是什么了。我最终使用 Dalli 代替,它在那里工作得很好。
不幸的是,默认的 ruby-openid 无法与 Dalli 作为客户端一起使用,并且似乎不再积极维护。我有一个一个分支,它既可以解决这个问题,也可以在 Gemfile 中使用。
无论如何,以下内容应该适合您:
初始化程序:
Gemfile:
抱歉,我知道这很痛苦。如果您找到更好的解决方案,请告诉我!
I'm guessing you're on Heroku, since I went through some trouble with this too. I ran into some problems using the standard Memcached library on Heroku, though I don't recall what they were now. I wound up using Dalli instead, which works great there.
Unfortunately, the default ruby-openid doesn't work with Dalli as a client, and doesn't appear to be actively maintained any longer. I have a fork that both fixes that issue and can be used in a Gemfile too.
Anyway, the following should work for you:
Initializer:
Gemfile:
Sorry, I know that this is a pain. If you find a better solution, please let me know!