当会话存储在memcached(Rails)中时,用户进行其他用户的会话

编程入门 行业动态 更新时间:2024-10-28 13:22:22
本文介绍了当会话存储在memcached(Rails)中时,用户进行其他用户的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

将会话存储在Memcached中时,我遇到了一个非常奇怪的问题.某些用户有时会参加其他会话.例如.约翰(John)以玛丽亚(Maria)身份登录,玛丽亚(Maria)以克里斯(Chris)等身份登录.

I have a very weird problem, when storing my session in Memcached. From time to time some users takes the session of others. E.g. John, becomes logged in as Maria, Maria as Chris and so on.

我使用Rails 2.3.4,但是早期版本的Rails也发生了相同的问题.我仅使用一台Memcache服务器,并且该服务器在同一台计算机上运行.调试的问题是我无法复制它.

I use Rails 2.3.4, but the same problem has been happening with earlier versions of Rails. I use only one Memcache server and it's running on the same machine. The problem with debugging this is that I can not reproduce it.

如果有人可以指导我如何解决此问题或对其进行调试,我将感到非常高兴.如果您正在使用Memcached进行会话并共享示例配置,我也会很高兴.

I'll be very glad if anybody can guide me how to solve this problem or debug it. I'll be also happy if you are using Memcached for sessions and you share your example confgs.

这些是我的配置:

# memcache options memcache_options = { :c_threshold => 10_000, :compression => false, :debug => false, :namespace => 'app_prod', :readonly => false, :urlencode => false, } memcache_servers = ['localhost:11211'] CACHE = MemCache.new(memcache_options) CACHE.servers = memcache_servers config.cache_store = :mem_cache_store, memcache_servers, memcache_options config.action_controller.session_store = :mem_cache_store config.action_controller.session = { :session_key => '_appname', :cache => CACHE, # :expires => 10, # :session_expires => 10, :secret => '5391aaaaaaaaaa56f8e8234beb638b97b32bbbbbbbbbbcc9dcae2beccccccccc89e8b508328def001a368da0678b061eb0e9d5a82a5ac94c8d35bd31a9a49e1' }

预先感谢您, 斯坦

推荐答案

我已经看到了这一点,发现调试起来非常困难.

I've seen this and found it very difficult to debug.

如果您使用的是乘客,则可能需要考虑使用保守的方法生成新服务器.

If you're using passenger, you may want to look at using the conservative method for spawning new servers.

默认方法是让服务器共享一个用于内存缓存的套接字.

The default method has servers sharing a single socket to memcache.

文档将对其进行详细讨论. www.modrails/documentation/Users%20guide%20Apache .html#_example_1_memcached_connection_sharing_harmful

The docs discuss it in more detail. www.modrails/documentation/Users%20guide%20Apache.html#_example_1_memcached_connection_sharing_harmful

更多推荐

当会话存储在memcached(Rails)中时,用户进行其他用户的会话

本文发布于:2023-11-11 16:37:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1578996.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:其他用户   中时   用户   memcached   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!